blob: 5dde974e3ae57fff775e62b5e96112c718843db7 [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// 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
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040033#import "GPBRuntimeTypes.h"
Thomas Van Lenten30650d82015-05-01 08:57:16 -040034#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
Thomas Van Lenten8c889572015-06-16 16:45:14 -040047NS_ASSUME_NONNULL_BEGIN
48
Sergio Campamá32fadc02016-08-08 07:15:02 -070049/**
Thomas Van Lenten5fd71ce2017-06-19 10:21:33 -040050 * @c GPBCodedOutputStream exception names.
51 **/
52extern NSString *const GPBCodedOutputStreamException_OutOfSpace;
53extern NSString *const GPBCodedOutputStreamException_WriteFailed;
54
55/**
Sergio Campamá32fadc02016-08-08 07:15:02 -070056 * 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 *
Thomas Van Lenten5fd71ce2017-06-19 10:21:33 -040061 * @note Any -write* api can raise the GPBCodedOutputStreamException_*
62 * exceptions.
63 *
Sergio Campamá32fadc02016-08-08 07:15:02 -070064 * @note Subclassing of GPBCodedOutputStream is NOT supported.
65 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040066@interface GPBCodedOutputStream : NSObject
67
Sergio Campamá32fadc02016-08-08 07:15:02 -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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040076+ (instancetype)streamWithData:(NSMutableData *)data;
Thomas Van Lenten36650a02016-03-07 12:07:03 -050077
Sergio Campamá32fadc02016-08-08 07:15:02 -070078/**
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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040085+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040086
Sergio Campamá32fadc02016-08-08 07:15:02 -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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040095- (instancetype)initWithData:(NSMutableData *)data;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040096
Sergio Campamá32fadc02016-08-08 07:15:02 -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 **/
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500104- (instancetype)initWithOutputStream:(NSOutputStream *)output;
105
Sergio Campamá32fadc02016-08-08 07:15:02 -0700106/**
107 * Flush any buffered data out.
108 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400109- (void)flush;
110
Sergio Campamá32fadc02016-08-08 07:15:02 -0700111/**
112 * Write the raw byte out.
113 *
114 * @param value The value to write out.
115 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400116- (void)writeRawByte:(uint8_t)value;
117
Sergio Campamá32fadc02016-08-08 07:15:02 -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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400124- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
125
Sergio Campamá32fadc02016-08-08 07:15:02 -0700126/**
127 * Write a 32bit value out in little endian format.
128 *
129 * @param value The value to write out.
130 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400131- (void)writeRawLittleEndian32:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700132/**
133 * Write a 64bit value out in little endian format.
134 *
135 * @param value The value to write out.
136 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400137- (void)writeRawLittleEndian64:(int64_t)value;
138
Sergio Campamá32fadc02016-08-08 07:15:02 -0700139/**
140 * Write a 32bit value out in varint format.
141 *
142 * @param value The value to write out.
143 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400144- (void)writeRawVarint32:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700145/**
146 * Write a 64bit value out in varint format.
147 *
148 * @param value The value to write out.
149 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400150- (void)writeRawVarint64:(int64_t)value;
151
Sergio Campamá32fadc02016-08-08 07:15:02 -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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400159- (void)writeRawVarintSizeTAs32:(size_t)value;
160
Sergio Campamá32fadc02016-08-08 07:15:02 -0700161/**
162 * Writes the contents of an NSData out.
163 *
164 * @param data The data to write out.
165 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400166- (void)writeRawData:(NSData *)data;
Sergio Campamá32fadc02016-08-08 07:15:02 -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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400174- (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.
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800180// clang-format off
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400181
Sergio Campamá32fadc02016-08-08 07:15:02 -0700182/**
183 * Write a double for the given field number.
184 *
185 * @param fieldNumber The field number assigned to the value.
186 * @param value The value to write out.
187 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400188- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700189/**
190 * Write a packed array of double for the given field number.
191 *
192 * @param fieldNumber The field number assigned to the values.
193 * @param values The values to write out.
194 * @param tag The tag assigned to the values.
195 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400196- (void)writeDoubleArray:(int32_t)fieldNumber
197 values:(GPBDoubleArray *)values
198 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700199/**
200 * Write a double without any tag.
201 *
202 * @param value The value to write out.
203 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400204- (void)writeDoubleNoTag:(double)value;
205
Sergio Campamá32fadc02016-08-08 07:15:02 -0700206/**
207 * Write a float for the given field number.
208 *
209 * @param fieldNumber The field number assigned to the value.
210 * @param value The value to write out.
211 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400212- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700213/**
214 * Write a packed array of float for the given field number.
215 *
216 * @param fieldNumber The field number assigned to the values.
217 * @param values The values to write out.
218 * @param tag The tag assigned to the values.
219 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400220- (void)writeFloatArray:(int32_t)fieldNumber
221 values:(GPBFloatArray *)values
222 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700223/**
224 * Write a float without any tag.
225 *
226 * @param value The value to write out.
227 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400228- (void)writeFloatNoTag:(float)value;
229
Sergio Campamá32fadc02016-08-08 07:15:02 -0700230/**
231 * Write a uint64_t for the given field number.
232 *
233 * @param fieldNumber The field number assigned to the value.
234 * @param value The value to write out.
235 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400236- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700237/**
238 * Write a packed array of uint64_t for the given field number.
239 *
240 * @param fieldNumber The field number assigned to the values.
241 * @param values The values to write out.
242 * @param tag The tag assigned to the values.
243 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400244- (void)writeUInt64Array:(int32_t)fieldNumber
245 values:(GPBUInt64Array *)values
246 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700247/**
248 * Write a uint64_t without any tag.
249 *
250 * @param value The value to write out.
251 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400252- (void)writeUInt64NoTag:(uint64_t)value;
253
Sergio Campamá32fadc02016-08-08 07:15:02 -0700254/**
255 * Write a int64_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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400260- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700261/**
262 * Write a packed array of int64_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 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400268- (void)writeInt64Array:(int32_t)fieldNumber
269 values:(GPBInt64Array *)values
270 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700271/**
272 * Write a int64_t without any tag.
273 *
274 * @param value The value to write out.
275 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400276- (void)writeInt64NoTag:(int64_t)value;
277
Sergio Campamá32fadc02016-08-08 07:15:02 -0700278/**
279 * Write a int32_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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400284- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700285/**
286 * Write a packed array of int32_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 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400292- (void)writeInt32Array:(int32_t)fieldNumber
293 values:(GPBInt32Array *)values
294 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700295/**
296 * Write a int32_t without any tag.
297 *
298 * @param value The value to write out.
299 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400300- (void)writeInt32NoTag:(int32_t)value;
301
Sergio Campamá32fadc02016-08-08 07:15:02 -0700302/**
303 * Write a uint32_t for the given field number.
304 *
305 * @param fieldNumber The field number assigned to the value.
306 * @param value The value to write out.
307 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400308- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700309/**
310 * Write a packed array of uint32_t for the given field number.
311 *
312 * @param fieldNumber The field number assigned to the values.
313 * @param values The values to write out.
314 * @param tag The tag assigned to the values.
315 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400316- (void)writeUInt32Array:(int32_t)fieldNumber
317 values:(GPBUInt32Array *)values
318 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700319/**
320 * Write a uint32_t without any tag.
321 *
322 * @param value The value to write out.
323 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400324- (void)writeUInt32NoTag:(uint32_t)value;
325
Sergio Campamá32fadc02016-08-08 07:15:02 -0700326/**
327 * Write a uint64_t for the given field number.
328 *
329 * @param fieldNumber The field number assigned to the value.
330 * @param value The value to write out.
331 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400332- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700333/**
334 * Write a packed array of uint64_t for the given field number.
335 *
336 * @param fieldNumber The field number assigned to the values.
337 * @param values The values to write out.
338 * @param tag The tag assigned to the values.
339 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400340- (void)writeFixed64Array:(int32_t)fieldNumber
341 values:(GPBUInt64Array *)values
342 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700343/**
344 * Write a uint64_t without any tag.
345 *
346 * @param value The value to write out.
347 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400348- (void)writeFixed64NoTag:(uint64_t)value;
349
Sergio Campamá32fadc02016-08-08 07:15:02 -0700350/**
351 * Write a uint32_t for the given field number.
352 *
353 * @param fieldNumber The field number assigned to the value.
354 * @param value The value to write out.
355 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400356- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700357/**
358 * Write a packed array of uint32_t for the given field number.
359 *
360 * @param fieldNumber The field number assigned to the values.
361 * @param values The values to write out.
362 * @param tag The tag assigned to the values.
363 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400364- (void)writeFixed32Array:(int32_t)fieldNumber
365 values:(GPBUInt32Array *)values
366 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700367/**
368 * Write a uint32_t without any tag.
369 *
370 * @param value The value to write out.
371 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400372- (void)writeFixed32NoTag:(uint32_t)value;
373
Sergio Campamá32fadc02016-08-08 07:15:02 -0700374/**
375 * Write a int32_t for the given field number.
376 *
377 * @param fieldNumber The field number assigned to the value.
378 * @param value The value to write out.
379 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400380- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700381/**
382 * Write a packed array of int32_t for the given field number.
383 *
384 * @param fieldNumber The field number assigned to the values.
385 * @param values The values to write out.
386 * @param tag The tag assigned to the values.
387 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400388- (void)writeSInt32Array:(int32_t)fieldNumber
389 values:(GPBInt32Array *)values
390 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700391/**
392 * Write a int32_t without any tag.
393 *
394 * @param value The value to write out.
395 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400396- (void)writeSInt32NoTag:(int32_t)value;
397
Sergio Campamá32fadc02016-08-08 07:15:02 -0700398/**
399 * Write a int64_t for the given field number.
400 *
401 * @param fieldNumber The field number assigned to the value.
402 * @param value The value to write out.
403 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400404- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700405/**
406 * Write a packed array of int64_t for the given field number.
407 *
408 * @param fieldNumber The field number assigned to the values.
409 * @param values The values to write out.
410 * @param tag The tag assigned to the values.
411 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400412- (void)writeSInt64Array:(int32_t)fieldNumber
413 values:(GPBInt64Array *)values
414 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700415/**
416 * Write a int64_t without any tag.
417 *
418 * @param value The value to write out.
419 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400420- (void)writeSInt64NoTag:(int64_t)value;
421
Sergio Campamá32fadc02016-08-08 07:15:02 -0700422/**
423 * Write a int64_t for the given field number.
424 *
425 * @param fieldNumber The field number assigned to the value.
426 * @param value The value to write out.
427 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400428- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700429/**
430 * Write a packed array of int64_t for the given field number.
431 *
432 * @param fieldNumber The field number assigned to the values.
433 * @param values The values to write out.
434 * @param tag The tag assigned to the values.
435 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400436- (void)writeSFixed64Array:(int32_t)fieldNumber
437 values:(GPBInt64Array *)values
438 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700439/**
440 * Write a int64_t without any tag.
441 *
442 * @param value The value to write out.
443 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400444- (void)writeSFixed64NoTag:(int64_t)value;
445
Sergio Campamá32fadc02016-08-08 07:15:02 -0700446/**
447 * Write a int32_t for the given field number.
448 *
449 * @param fieldNumber The field number assigned to the value.
450 * @param value The value to write out.
451 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400452- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700453/**
454 * Write a packed array of int32_t for the given field number.
455 *
456 * @param fieldNumber The field number assigned to the values.
457 * @param values The values to write out.
458 * @param tag The tag assigned to the values.
459 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400460- (void)writeSFixed32Array:(int32_t)fieldNumber
461 values:(GPBInt32Array *)values
462 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700463/**
464 * Write a int32_t without any tag.
465 *
466 * @param value The value to write out.
467 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400468- (void)writeSFixed32NoTag:(int32_t)value;
469
Sergio Campamá32fadc02016-08-08 07:15:02 -0700470/**
471 * Write a BOOL for the given field number.
472 *
473 * @param fieldNumber The field number assigned to the value.
474 * @param value The value to write out.
475 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400476- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700477/**
478 * Write a packed array of BOOL for the given field number.
479 *
480 * @param fieldNumber The field number assigned to the values.
481 * @param values The values to write out.
482 * @param tag The tag assigned to the values.
483 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400484- (void)writeBoolArray:(int32_t)fieldNumber
485 values:(GPBBoolArray *)values
486 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700487/**
488 * Write a BOOL without any tag.
489 *
490 * @param value The value to write out.
491 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400492- (void)writeBoolNoTag:(BOOL)value;
493
Sergio Campamá32fadc02016-08-08 07:15:02 -0700494/**
495 * Write a int32_t for the given field number.
496 *
497 * @param fieldNumber The field number assigned to the value.
498 * @param value The value to write out.
499 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400500- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700501/**
502 * Write a packed array of int32_t for the given field number.
503 *
504 * @param fieldNumber The field number assigned to the values.
505 * @param values The values to write out.
506 * @param tag The tag assigned to the values.
507 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400508- (void)writeEnumArray:(int32_t)fieldNumber
509 values:(GPBEnumArray *)values
510 tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700511/**
512 * Write a int32_t without any tag.
513 *
514 * @param value The value to write out.
515 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400516- (void)writeEnumNoTag:(int32_t)value;
517
Sergio Campamá32fadc02016-08-08 07:15:02 -0700518/**
519 * Write a NSString for the given field number.
520 *
521 * @param fieldNumber The field number assigned to the value.
522 * @param value The value to write out.
523 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400524- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700525/**
526 * Write an array of NSString for the given field number.
527 *
528 * @param fieldNumber The field number assigned to the values.
529 * @param values The values to write out.
530 **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800531- (void)writeStringArray:(int32_t)fieldNumber
532 values:(NSArray<NSString*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700533/**
534 * Write a NSString without any tag.
535 *
536 * @param value The value to write out.
537 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400538- (void)writeStringNoTag:(NSString *)value;
539
Sergio Campamá32fadc02016-08-08 07:15:02 -0700540/**
541 * Write a GPBMessage for the given field number.
542 *
543 * @param fieldNumber The field number assigned to the value.
544 * @param value The value to write out.
545 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400546- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700547/**
548 * Write an array of GPBMessage for the given field number.
549 *
550 * @param fieldNumber The field number assigned to the values.
551 * @param values The values to write out.
552 **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800553- (void)writeMessageArray:(int32_t)fieldNumber
554 values:(NSArray<GPBMessage*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700555/**
556 * Write a GPBMessage without any tag.
557 *
558 * @param value The value to write out.
559 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400560- (void)writeMessageNoTag:(GPBMessage *)value;
561
Sergio Campamá32fadc02016-08-08 07:15:02 -0700562/**
563 * Write a NSData for the given field number.
564 *
565 * @param fieldNumber The field number assigned to the value.
566 * @param value The value to write out.
567 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400568- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700569/**
570 * Write an array of NSData for the given field number.
571 *
572 * @param fieldNumber The field number assigned to the values.
573 * @param values The values to write out.
574 **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800575- (void)writeBytesArray:(int32_t)fieldNumber
576 values:(NSArray<NSData*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700577/**
578 * Write a NSData without any tag.
579 *
580 * @param value The value to write out.
581 **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400582- (void)writeBytesNoTag:(NSData *)value;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400583
Sergio Campamá32fadc02016-08-08 07:15:02 -0700584/**
585 * Write a GPBMessage for the given field number.
586 *
587 * @param fieldNumber The field number assigned to the value.
588 * @param value The value to write out.
589 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400590- (void)writeGroup:(int32_t)fieldNumber
591 value:(GPBMessage *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700592/**
593 * Write an array of GPBMessage for the given field number.
594 *
595 * @param fieldNumber The field number assigned to the values.
596 * @param values The values to write out.
597 **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800598- (void)writeGroupArray:(int32_t)fieldNumber
599 values:(NSArray<GPBMessage*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700600/**
601 * Write a GPBMessage without any tag (but does write the endGroup tag).
602 *
603 * @param fieldNumber The field number assigned to the value.
604 * @param value The value to write out.
605 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400606- (void)writeGroupNoTag:(int32_t)fieldNumber
607 value:(GPBMessage *)value;
608
Sergio Campamá32fadc02016-08-08 07:15:02 -0700609/**
610 * Write a GPBUnknownFieldSet 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 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400615- (void)writeUnknownGroup:(int32_t)fieldNumber
616 value:(GPBUnknownFieldSet *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700617/**
618 * Write an array of GPBUnknownFieldSet for the given field number.
619 *
620 * @param fieldNumber The field number assigned to the values.
621 * @param values The values to write out.
622 **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800623- (void)writeUnknownGroupArray:(int32_t)fieldNumber
624 values:(NSArray<GPBUnknownFieldSet*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700625/**
626 * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
627 *
628 * @param fieldNumber The field number assigned to the value.
629 * @param value The value to write out.
630 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400631- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
632 value:(GPBUnknownFieldSet *)value;
633
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800634// clang-format on
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400635//%PDDM-EXPAND-END _WRITE_DECLS()
636
Sergio Campamá32fadc02016-08-08 07:15:02 -0700637/**
638Write a MessageSet extension field to the stream. For historical reasons,
639the wire format differs from normal fields.
640
641@param fieldNumber The extension field number to write out.
642@param value The message from where to get the extension.
643*/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400644- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
645
Sergio Campamá32fadc02016-08-08 07:15:02 -0700646/**
647Write an unparsed MessageSet extension field to the stream. For historical
648reasons, the wire format differs from normal fields.
649
650@param fieldNumber The extension field number to write out.
651@param value The raw message from where to get the extension.
652*/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400653- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
654
655@end
656
Thomas Van Lenten8c889572015-06-16 16:45:14 -0400657NS_ASSUME_NONNULL_END
658
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400659// Write methods for types that can be in packed arrays.
660//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
Sergio Campamá32fadc02016-08-08 07:15:02 -0700661//%/**
662//% * Write a TYPE for the given field number.
663//% *
664//% * @param fieldNumber The field number assigned to the value.
665//% * @param value The value to write out.
666//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400667//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700668//%/**
669//% * Write a packed array of TYPE for the given field number.
670//% *
671//% * @param fieldNumber The field number assigned to the values.
672//% * @param values The values to write out.
673//% * @param tag The tag assigned to the values.
674//% **/
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400675//%- (void)write##NAME##Array:(int32_t)fieldNumber
676//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
677//% NAME$S tag:(uint32_t)tag;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700678//%/**
679//% * Write a TYPE without any tag.
680//% *
681//% * @param value The value to write out.
682//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400683//%- (void)write##NAME##NoTag:(TYPE)value;
684//%
685// Write methods for types that aren't in packed arrays.
686//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
Sergio Campamá32fadc02016-08-08 07:15:02 -0700687//%/**
688//% * Write a TYPE for the given field number.
689//% *
690//% * @param fieldNumber The field number assigned to the value.
691//% * @param value The value to write out.
692//% **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500693//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700694//%/**
695//% * Write an array of TYPE for the given field number.
696//% *
697//% * @param fieldNumber The field number assigned to the values.
698//% * @param values The values to write out.
699//% **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800700//%- (void)write##NAME##Array:(int32_t)fieldNumber
701//% NAME$S values:(NSArray<##TYPE##*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700702//%/**
703//% * Write a TYPE without any tag.
704//% *
705//% * @param value The value to write out.
706//% **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500707//%- (void)write##NAME##NoTag:(TYPE *)value;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400708//%
709// Special write methods for Groups.
710//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
Sergio Campamá32fadc02016-08-08 07:15:02 -0700711//%/**
712//% * Write a TYPE for the given field number.
713//% *
714//% * @param fieldNumber The field number assigned to the value.
715//% * @param value The value to write out.
716//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400717//%- (void)write##NAME:(int32_t)fieldNumber
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500718//% NAME$S value:(TYPE *)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700719//%/**
720//% * Write an array of TYPE for the given field number.
721//% *
722//% * @param fieldNumber The field number assigned to the values.
723//% * @param values The values to write out.
724//% **/
Dave MacLachlanab48ecf2020-01-20 13:47:20 -0800725//%- (void)write##NAME##Array:(int32_t)fieldNumber
726//% NAME$S values:(NSArray<##TYPE##*> *)values;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700727//%/**
728//% * Write a TYPE without any tag (but does write the endGroup tag).
729//% *
730//% * @param fieldNumber The field number assigned to the value.
731//% * @param value The value to write out.
732//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400733//%- (void)write##NAME##NoTag:(int32_t)fieldNumber
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500734//% NAME$S value:(TYPE *)value;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400735//%
736
737// One macro to hide it all up above.
738//%PDDM-DEFINE _WRITE_DECLS()
739//%_WRITE_PACKABLE_DECLS(Double, Double, double)
740//%_WRITE_PACKABLE_DECLS(Float, Float, float)
741//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
742//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
743//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
744//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
745//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
746//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
747//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
748//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
749//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
750//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
751//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
752//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500753//%_WRITE_UNPACKABLE_DECLS(String, NSString)
754//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
755//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
756//%_WRITE_GROUP_DECLS(Group, GPBMessage)
757//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)