blob: 23c404b8533a6878e64c624b948a7861e48b4fac [file] [log] [blame]
Brian Silverman9c614bc2016-02-15 20:20:02 -05001// 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
31#import <Foundation/Foundation.h>
32
33#import "GPBRuntimeTypes.h"
34#import "GPBWireFormat.h"
35
36@class GPBBoolArray;
37@class GPBDoubleArray;
38@class GPBEnumArray;
39@class GPBFloatArray;
40@class GPBMessage;
41@class GPBInt32Array;
42@class GPBInt64Array;
43@class GPBUInt32Array;
44@class GPBUInt64Array;
45@class GPBUnknownFieldSet;
46
47NS_ASSUME_NONNULL_BEGIN
48
Austin Schuh40c16522018-10-28 20:27:54 -070049/**
50 * @c GPBCodedOutputStream exception names.
51 **/
52extern NSString *const GPBCodedOutputStreamException_OutOfSpace;
53extern NSString *const GPBCodedOutputStreamException_WriteFailed;
54
55/**
56 * Writes out protocol message fields.
57 *
58 * The common uses of protocol buffers shouldn't need to use this class.
59 * GPBMessage's provide a -data method that will serialize the message for you.
60 *
61 * @note Any -write* api can raise the GPBCodedOutputStreamException_*
62 * exceptions.
63 *
64 * @note Subclassing of GPBCodedOutputStream is NOT supported.
65 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050066@interface GPBCodedOutputStream : NSObject
67
Austin Schuh40c16522018-10-28 20:27:54 -070068/**
69 * Creates a stream to fill in the given data. Data must be sized to fit or
70 * an error will be raised when out of space.
71 *
72 * @param data The data where the stream will be written to.
73 *
74 * @return A newly instanced GPBCodedOutputStream.
75 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050076+ (instancetype)streamWithData:(NSMutableData *)data;
Austin Schuh40c16522018-10-28 20:27:54 -070077
78/**
79 * Creates a stream to write into the given NSOutputStream.
80 *
81 * @param output The output stream where the stream will be written to.
82 *
83 * @return A newly instanced GPBCodedOutputStream.
84 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050085+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;
Brian Silverman9c614bc2016-02-15 20:20:02 -050086
Austin Schuh40c16522018-10-28 20:27:54 -070087/**
88 * Initializes a stream to fill in the given data. Data must be sized to fit
89 * or an error will be raised when out of space.
90 *
91 * @param data The data where the stream will be written to.
92 *
93 * @return A newly initialized GPBCodedOutputStream.
94 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050095- (instancetype)initWithData:(NSMutableData *)data;
Brian Silverman9c614bc2016-02-15 20:20:02 -050096
Austin Schuh40c16522018-10-28 20:27:54 -070097/**
98 * Initializes a stream to write into the given @c NSOutputStream.
99 *
100 * @param output The output stream where the stream will be written to.
101 *
102 * @return A newly initialized GPBCodedOutputStream.
103 **/
104- (instancetype)initWithOutputStream:(NSOutputStream *)output;
105
106/**
107 * Flush any buffered data out.
108 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500109- (void)flush;
110
Austin Schuh40c16522018-10-28 20:27:54 -0700111/**
112 * Write the raw byte out.
113 *
114 * @param value The value to write out.
115 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500116- (void)writeRawByte:(uint8_t)value;
117
Austin Schuh40c16522018-10-28 20:27:54 -0700118/**
119 * Write the tag for the given field number and wire format.
120 *
121 * @param fieldNumber The field number.
122 * @param format The wire format the data for the field will be in.
123 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500124- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
125
Austin Schuh40c16522018-10-28 20:27:54 -0700126/**
127 * Write a 32bit value out in little endian format.
128 *
129 * @param value The value to write out.
130 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500131- (void)writeRawLittleEndian32:(int32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700132/**
133 * Write a 64bit value out in little endian format.
134 *
135 * @param value The value to write out.
136 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500137- (void)writeRawLittleEndian64:(int64_t)value;
138
Austin Schuh40c16522018-10-28 20:27:54 -0700139/**
140 * Write a 32bit value out in varint format.
141 *
142 * @param value The value to write out.
143 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500144- (void)writeRawVarint32:(int32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700145/**
146 * Write a 64bit value out in varint format.
147 *
148 * @param value The value to write out.
149 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500150- (void)writeRawVarint64:(int64_t)value;
151
Austin Schuh40c16522018-10-28 20:27:54 -0700152/**
153 * Write a size_t out as a 32bit varint value.
154 *
155 * @note This will truncate 64 bit values to 32.
156 *
157 * @param value The value to write out.
158 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500159- (void)writeRawVarintSizeTAs32:(size_t)value;
160
Austin Schuh40c16522018-10-28 20:27:54 -0700161/**
162 * Writes the contents of an NSData out.
163 *
164 * @param data The data to write out.
165 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500166- (void)writeRawData:(NSData *)data;
Austin Schuh40c16522018-10-28 20:27:54 -0700167/**
168 * Writes out the given data.
169 *
170 * @param data The data blob to write out.
171 * @param offset The offset into the blob to start writing out.
172 * @param length The number of bytes from the blob to write out.
173 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500174- (void)writeRawPtr:(const void *)data
175 offset:(size_t)offset
176 length:(size_t)length;
177
178//%PDDM-EXPAND _WRITE_DECLS()
179// This block of code is generated, do not edit it directly.
180
Austin Schuh40c16522018-10-28 20:27:54 -0700181/**
182 * Write a double for the given field number.
183 *
184 * @param fieldNumber The field number assigned to the value.
185 * @param value The value to write out.
186 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500187- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700188/**
189 * Write a packed array of double for the given field number.
190 *
191 * @param fieldNumber The field number assigned to the values.
192 * @param values The values to write out.
193 * @param tag The tag assigned to the values.
194 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500195- (void)writeDoubleArray:(int32_t)fieldNumber
196 values:(GPBDoubleArray *)values
197 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700198/**
199 * Write a double without any tag.
200 *
201 * @param value The value to write out.
202 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500203- (void)writeDoubleNoTag:(double)value;
204
Austin Schuh40c16522018-10-28 20:27:54 -0700205/**
206 * Write a float for the given field number.
207 *
208 * @param fieldNumber The field number assigned to the value.
209 * @param value The value to write out.
210 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500211- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700212/**
213 * Write a packed array of float for the given field number.
214 *
215 * @param fieldNumber The field number assigned to the values.
216 * @param values The values to write out.
217 * @param tag The tag assigned to the values.
218 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500219- (void)writeFloatArray:(int32_t)fieldNumber
220 values:(GPBFloatArray *)values
221 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700222/**
223 * Write a float without any tag.
224 *
225 * @param value The value to write out.
226 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500227- (void)writeFloatNoTag:(float)value;
228
Austin Schuh40c16522018-10-28 20:27:54 -0700229/**
230 * Write a uint64_t for the given field number.
231 *
232 * @param fieldNumber The field number assigned to the value.
233 * @param value The value to write out.
234 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500235- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700236/**
237 * Write a packed array of uint64_t for the given field number.
238 *
239 * @param fieldNumber The field number assigned to the values.
240 * @param values The values to write out.
241 * @param tag The tag assigned to the values.
242 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500243- (void)writeUInt64Array:(int32_t)fieldNumber
244 values:(GPBUInt64Array *)values
245 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700246/**
247 * Write a uint64_t without any tag.
248 *
249 * @param value The value to write out.
250 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500251- (void)writeUInt64NoTag:(uint64_t)value;
252
Austin Schuh40c16522018-10-28 20:27:54 -0700253/**
254 * Write a int64_t for the given field number.
255 *
256 * @param fieldNumber The field number assigned to the value.
257 * @param value The value to write out.
258 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500259- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700260/**
261 * Write a packed array of int64_t for the given field number.
262 *
263 * @param fieldNumber The field number assigned to the values.
264 * @param values The values to write out.
265 * @param tag The tag assigned to the values.
266 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500267- (void)writeInt64Array:(int32_t)fieldNumber
268 values:(GPBInt64Array *)values
269 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700270/**
271 * Write a int64_t without any tag.
272 *
273 * @param value The value to write out.
274 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500275- (void)writeInt64NoTag:(int64_t)value;
276
Austin Schuh40c16522018-10-28 20:27:54 -0700277/**
278 * Write a int32_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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500283- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700284/**
285 * Write a packed array of int32_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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500291- (void)writeInt32Array:(int32_t)fieldNumber
292 values:(GPBInt32Array *)values
293 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700294/**
295 * Write a int32_t without any tag.
296 *
297 * @param value The value to write out.
298 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500299- (void)writeInt32NoTag:(int32_t)value;
300
Austin Schuh40c16522018-10-28 20:27:54 -0700301/**
302 * Write a uint32_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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500307- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700308/**
309 * Write a packed array of uint32_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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500315- (void)writeUInt32Array:(int32_t)fieldNumber
316 values:(GPBUInt32Array *)values
317 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700318/**
319 * Write a uint32_t without any tag.
320 *
321 * @param value The value to write out.
322 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500323- (void)writeUInt32NoTag:(uint32_t)value;
324
Austin Schuh40c16522018-10-28 20:27:54 -0700325/**
326 * Write a uint64_t for the given field number.
327 *
328 * @param fieldNumber The field number assigned to the value.
329 * @param value The value to write out.
330 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500331- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700332/**
333 * Write a packed array of uint64_t for the given field number.
334 *
335 * @param fieldNumber The field number assigned to the values.
336 * @param values The values to write out.
337 * @param tag The tag assigned to the values.
338 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500339- (void)writeFixed64Array:(int32_t)fieldNumber
340 values:(GPBUInt64Array *)values
341 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700342/**
343 * Write a uint64_t without any tag.
344 *
345 * @param value The value to write out.
346 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500347- (void)writeFixed64NoTag:(uint64_t)value;
348
Austin Schuh40c16522018-10-28 20:27:54 -0700349/**
350 * Write a uint32_t for the given field number.
351 *
352 * @param fieldNumber The field number assigned to the value.
353 * @param value The value to write out.
354 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500355- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700356/**
357 * Write a packed array of uint32_t for the given field number.
358 *
359 * @param fieldNumber The field number assigned to the values.
360 * @param values The values to write out.
361 * @param tag The tag assigned to the values.
362 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500363- (void)writeFixed32Array:(int32_t)fieldNumber
364 values:(GPBUInt32Array *)values
365 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700366/**
367 * Write a uint32_t without any tag.
368 *
369 * @param value The value to write out.
370 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500371- (void)writeFixed32NoTag:(uint32_t)value;
372
Austin Schuh40c16522018-10-28 20:27:54 -0700373/**
374 * Write a int32_t for the given field number.
375 *
376 * @param fieldNumber The field number assigned to the value.
377 * @param value The value to write out.
378 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500379- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700380/**
381 * Write a packed array of int32_t for the given field number.
382 *
383 * @param fieldNumber The field number assigned to the values.
384 * @param values The values to write out.
385 * @param tag The tag assigned to the values.
386 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500387- (void)writeSInt32Array:(int32_t)fieldNumber
388 values:(GPBInt32Array *)values
389 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700390/**
391 * Write a int32_t without any tag.
392 *
393 * @param value The value to write out.
394 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500395- (void)writeSInt32NoTag:(int32_t)value;
396
Austin Schuh40c16522018-10-28 20:27:54 -0700397/**
398 * Write a int64_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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500403- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700404/**
405 * Write a packed array of int64_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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500411- (void)writeSInt64Array:(int32_t)fieldNumber
412 values:(GPBInt64Array *)values
413 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700414/**
415 * Write a int64_t without any tag.
416 *
417 * @param value The value to write out.
418 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500419- (void)writeSInt64NoTag:(int64_t)value;
420
Austin Schuh40c16522018-10-28 20:27:54 -0700421/**
422 * Write a int64_t for the given field number.
423 *
424 * @param fieldNumber The field number assigned to the value.
425 * @param value The value to write out.
426 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500427- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700428/**
429 * Write a packed array of int64_t for the given field number.
430 *
431 * @param fieldNumber The field number assigned to the values.
432 * @param values The values to write out.
433 * @param tag The tag assigned to the values.
434 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500435- (void)writeSFixed64Array:(int32_t)fieldNumber
436 values:(GPBInt64Array *)values
437 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700438/**
439 * Write a int64_t without any tag.
440 *
441 * @param value The value to write out.
442 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500443- (void)writeSFixed64NoTag:(int64_t)value;
444
Austin Schuh40c16522018-10-28 20:27:54 -0700445/**
446 * Write a int32_t for the given field number.
447 *
448 * @param fieldNumber The field number assigned to the value.
449 * @param value The value to write out.
450 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500451- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700452/**
453 * Write a packed array of int32_t for the given field number.
454 *
455 * @param fieldNumber The field number assigned to the values.
456 * @param values The values to write out.
457 * @param tag The tag assigned to the values.
458 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500459- (void)writeSFixed32Array:(int32_t)fieldNumber
460 values:(GPBInt32Array *)values
461 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700462/**
463 * Write a int32_t without any tag.
464 *
465 * @param value The value to write out.
466 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500467- (void)writeSFixed32NoTag:(int32_t)value;
468
Austin Schuh40c16522018-10-28 20:27:54 -0700469/**
470 * Write a BOOL for the given field number.
471 *
472 * @param fieldNumber The field number assigned to the value.
473 * @param value The value to write out.
474 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500475- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700476/**
477 * Write a packed array of BOOL for the given field number.
478 *
479 * @param fieldNumber The field number assigned to the values.
480 * @param values The values to write out.
481 * @param tag The tag assigned to the values.
482 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500483- (void)writeBoolArray:(int32_t)fieldNumber
484 values:(GPBBoolArray *)values
485 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700486/**
487 * Write a BOOL without any tag.
488 *
489 * @param value The value to write out.
490 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500491- (void)writeBoolNoTag:(BOOL)value;
492
Austin Schuh40c16522018-10-28 20:27:54 -0700493/**
494 * Write a int32_t for the given field number.
495 *
496 * @param fieldNumber The field number assigned to the value.
497 * @param value The value to write out.
498 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500499- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700500/**
501 * Write a packed array of int32_t for the given field number.
502 *
503 * @param fieldNumber The field number assigned to the values.
504 * @param values The values to write out.
505 * @param tag The tag assigned to the values.
506 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500507- (void)writeEnumArray:(int32_t)fieldNumber
508 values:(GPBEnumArray *)values
509 tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700510/**
511 * Write a int32_t without any tag.
512 *
513 * @param value The value to write out.
514 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500515- (void)writeEnumNoTag:(int32_t)value;
516
Austin Schuh40c16522018-10-28 20:27:54 -0700517/**
518 * Write a NSString for the given field number.
519 *
520 * @param fieldNumber The field number assigned to the value.
521 * @param value The value to write out.
522 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500523- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700524/**
525 * Write an array of NSString for the given field number.
526 *
527 * @param fieldNumber The field number assigned to the values.
528 * @param values The values to write out.
529 **/
530- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
531/**
532 * Write a NSString without any tag.
533 *
534 * @param value The value to write out.
535 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500536- (void)writeStringNoTag:(NSString *)value;
537
Austin Schuh40c16522018-10-28 20:27:54 -0700538/**
539 * Write a GPBMessage for the given field number.
540 *
541 * @param fieldNumber The field number assigned to the value.
542 * @param value The value to write out.
543 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500544- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700545/**
546 * Write an array of GPBMessage for the given field number.
547 *
548 * @param fieldNumber The field number assigned to the values.
549 * @param values The values to write out.
550 **/
551- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
552/**
553 * Write a GPBMessage without any tag.
554 *
555 * @param value The value to write out.
556 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500557- (void)writeMessageNoTag:(GPBMessage *)value;
558
Austin Schuh40c16522018-10-28 20:27:54 -0700559/**
560 * Write a NSData 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 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500565- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700566/**
567 * Write an array of NSData for the given field number.
568 *
569 * @param fieldNumber The field number assigned to the values.
570 * @param values The values to write out.
571 **/
572- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
573/**
574 * Write a NSData without any tag.
575 *
576 * @param value The value to write out.
577 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500578- (void)writeBytesNoTag:(NSData *)value;
579
Austin Schuh40c16522018-10-28 20:27:54 -0700580/**
581 * Write a GPBMessage for the given field number.
582 *
583 * @param fieldNumber The field number assigned to the value.
584 * @param value The value to write out.
585 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500586- (void)writeGroup:(int32_t)fieldNumber
587 value:(GPBMessage *)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700588/**
589 * Write an array of GPBMessage for the given field number.
590 *
591 * @param fieldNumber The field number assigned to the values.
592 * @param values The values to write out.
593 **/
594- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
595/**
596 * Write a GPBMessage without any tag (but does write the endGroup tag).
597 *
598 * @param fieldNumber The field number assigned to the value.
599 * @param value The value to write out.
600 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500601- (void)writeGroupNoTag:(int32_t)fieldNumber
602 value:(GPBMessage *)value;
603
Austin Schuh40c16522018-10-28 20:27:54 -0700604/**
605 * Write a GPBUnknownFieldSet for the given field number.
606 *
607 * @param fieldNumber The field number assigned to the value.
608 * @param value The value to write out.
609 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500610- (void)writeUnknownGroup:(int32_t)fieldNumber
611 value:(GPBUnknownFieldSet *)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700612/**
613 * Write an array of GPBUnknownFieldSet for the given field number.
614 *
615 * @param fieldNumber The field number assigned to the values.
616 * @param values The values to write out.
617 **/
618- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
619/**
620 * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
621 *
622 * @param fieldNumber The field number assigned to the value.
623 * @param value The value to write out.
624 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500625- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
626 value:(GPBUnknownFieldSet *)value;
627
628//%PDDM-EXPAND-END _WRITE_DECLS()
629
Austin Schuh40c16522018-10-28 20:27:54 -0700630/**
631Write a MessageSet extension field to the stream. For historical reasons,
632the wire format differs from normal fields.
633
634@param fieldNumber The extension field number to write out.
635@param value The message from where to get the extension.
636*/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500637- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
638
Austin Schuh40c16522018-10-28 20:27:54 -0700639/**
640Write an unparsed MessageSet extension field to the stream. For historical
641reasons, the wire format differs from normal fields.
642
643@param fieldNumber The extension field number to write out.
644@param value The raw message from where to get the extension.
645*/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500646- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
647
648@end
649
Brian Silverman9c614bc2016-02-15 20:20:02 -0500650NS_ASSUME_NONNULL_END
651
652// Write methods for types that can be in packed arrays.
653//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
Austin Schuh40c16522018-10-28 20:27:54 -0700654//%/**
655//% * Write a TYPE for the given field number.
656//% *
657//% * @param fieldNumber The field number assigned to the value.
658//% * @param value The value to write out.
659//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500660//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
Austin Schuh40c16522018-10-28 20:27:54 -0700661//%/**
662//% * Write a packed array of TYPE for the given field number.
663//% *
664//% * @param fieldNumber The field number assigned to the values.
665//% * @param values The values to write out.
666//% * @param tag The tag assigned to the values.
667//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500668//%- (void)write##NAME##Array:(int32_t)fieldNumber
669//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
670//% NAME$S tag:(uint32_t)tag;
Austin Schuh40c16522018-10-28 20:27:54 -0700671//%/**
672//% * Write a TYPE without any tag.
673//% *
674//% * @param value The value to write out.
675//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500676//%- (void)write##NAME##NoTag:(TYPE)value;
677//%
678// Write methods for types that aren't in packed arrays.
679//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
Austin Schuh40c16522018-10-28 20:27:54 -0700680//%/**
681//% * Write a TYPE for the given field number.
682//% *
683//% * @param fieldNumber The field number assigned to the value.
684//% * @param value The value to write out.
685//% **/
686//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
687//%/**
688//% * Write an array of TYPE for the given field number.
689//% *
690//% * @param fieldNumber The field number assigned to the values.
691//% * @param values The values to write out.
692//% **/
693//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
694//%/**
695//% * Write a TYPE without any tag.
696//% *
697//% * @param value The value to write out.
698//% **/
699//%- (void)write##NAME##NoTag:(TYPE *)value;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500700//%
701// Special write methods for Groups.
702//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
Austin Schuh40c16522018-10-28 20:27:54 -0700703//%/**
704//% * Write a TYPE for the given field number.
705//% *
706//% * @param fieldNumber The field number assigned to the value.
707//% * @param value The value to write out.
708//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500709//%- (void)write##NAME:(int32_t)fieldNumber
Austin Schuh40c16522018-10-28 20:27:54 -0700710//% NAME$S value:(TYPE *)value;
711//%/**
712//% * Write an array of TYPE for the given field number.
713//% *
714//% * @param fieldNumber The field number assigned to the values.
715//% * @param values The values to write out.
716//% **/
717//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
718//%/**
719//% * Write a TYPE without any tag (but does write the endGroup tag).
720//% *
721//% * @param fieldNumber The field number assigned to the value.
722//% * @param value The value to write out.
723//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500724//%- (void)write##NAME##NoTag:(int32_t)fieldNumber
Austin Schuh40c16522018-10-28 20:27:54 -0700725//% NAME$S value:(TYPE *)value;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500726//%
727
728// One macro to hide it all up above.
729//%PDDM-DEFINE _WRITE_DECLS()
730//%_WRITE_PACKABLE_DECLS(Double, Double, double)
731//%_WRITE_PACKABLE_DECLS(Float, Float, float)
732//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
733//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
734//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
735//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
736//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
737//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
738//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
739//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
740//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
741//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
742//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
743//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
Austin Schuh40c16522018-10-28 20:27:54 -0700744//%_WRITE_UNPACKABLE_DECLS(String, NSString)
745//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
746//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
747//%_WRITE_GROUP_DECLS(Group, GPBMessage)
748//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)