blob: e67efd2d428500183ae3fcf6b78502e60b852269 [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
Thomas Van Lenten36650a02016-03-07 12:07:03 -050049/// Writes out protocol message fields.
50///
51/// The common uses of protocol buffers shouldn't need to use this class.
52/// @c GPBMessage's provide a @c -data method that will serialize the message
53/// for you.
54///
55/// @note Subclassing of GPBCodedOutputStream is NOT supported.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040056@interface GPBCodedOutputStream : NSObject
57
Thomas Van Lenten36650a02016-03-07 12:07:03 -050058/// Creates a stream to fill in the given data. Data must be sized to fit or
59/// an error will be raised when out of space.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040060+ (instancetype)streamWithData:(NSMutableData *)data;
Thomas Van Lenten36650a02016-03-07 12:07:03 -050061
62/// Creates a stream to write into the given @c NSOutputStream.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040063+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040064
Thomas Van Lenten36650a02016-03-07 12:07:03 -050065/// Initializes a stream to fill in the given data. Data must be sized to fit
66/// or an error will be raised when out of space.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040067- (instancetype)initWithData:(NSMutableData *)data;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040068
Thomas Van Lenten36650a02016-03-07 12:07:03 -050069/// Initializes a stream to write into the given @c NSOutputStream.
70- (instancetype)initWithOutputStream:(NSOutputStream *)output;
71
72/// Flush any buffered data out.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040073- (void)flush;
74
Thomas Van Lenten36650a02016-03-07 12:07:03 -050075/// Write the raw byte out.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040076- (void)writeRawByte:(uint8_t)value;
77
Thomas Van Lenten36650a02016-03-07 12:07:03 -050078/// Write the tag for the given field number and wire format.
79///
80/// @param fieldNumber The field number.
81/// @param format The wire format the data for the field will be in.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040082- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
83
Thomas Van Lenten36650a02016-03-07 12:07:03 -050084/// Write a 32bit value out in little endian format.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040085- (void)writeRawLittleEndian32:(int32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -050086/// Write a 64bit value out in little endian format.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040087- (void)writeRawLittleEndian64:(int64_t)value;
88
Thomas Van Lenten36650a02016-03-07 12:07:03 -050089/// Write a 32bit value out in varint format.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040090- (void)writeRawVarint32:(int32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -050091/// Write a 64bit value out in varint format.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040092- (void)writeRawVarint64:(int64_t)value;
93
Thomas Van Lenten36650a02016-03-07 12:07:03 -050094/// Write a size_t out as a 32bit varint value.
95///
96/// @note This will truncate 64 bit values to 32.
Thomas Van Lenten30650d82015-05-01 08:57:16 -040097- (void)writeRawVarintSizeTAs32:(size_t)value;
98
Thomas Van Lenten36650a02016-03-07 12:07:03 -050099/// Writes the contents of an @c NSData out.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400100- (void)writeRawData:(NSData *)data;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500101/// Writes out the given data.
102///
103/// @param data The data blob to write out.
104/// @param offset The offset into the blob to start writing out.
105/// @param length The number of bytes from the blob to write out.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400106- (void)writeRawPtr:(const void *)data
107 offset:(size_t)offset
108 length:(size_t)length;
109
110//%PDDM-EXPAND _WRITE_DECLS()
111// This block of code is generated, do not edit it directly.
112
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500113/// Write a double for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400114- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500115/// Write a packaged array of double for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400116- (void)writeDoubleArray:(int32_t)fieldNumber
117 values:(GPBDoubleArray *)values
118 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500119/// Write a double without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400120- (void)writeDoubleNoTag:(double)value;
121
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500122/// Write a float for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400123- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500124/// Write a packaged array of float for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400125- (void)writeFloatArray:(int32_t)fieldNumber
126 values:(GPBFloatArray *)values
127 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500128/// Write a float without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400129- (void)writeFloatNoTag:(float)value;
130
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500131/// Write a uint64_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400132- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500133/// Write a packaged array of uint64_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400134- (void)writeUInt64Array:(int32_t)fieldNumber
135 values:(GPBUInt64Array *)values
136 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500137/// Write a uint64_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400138- (void)writeUInt64NoTag:(uint64_t)value;
139
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500140/// Write a int64_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400141- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500142/// Write a packaged array of int64_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400143- (void)writeInt64Array:(int32_t)fieldNumber
144 values:(GPBInt64Array *)values
145 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500146/// Write a int64_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400147- (void)writeInt64NoTag:(int64_t)value;
148
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500149/// Write a int32_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400150- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500151/// Write a packaged array of int32_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400152- (void)writeInt32Array:(int32_t)fieldNumber
153 values:(GPBInt32Array *)values
154 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500155/// Write a int32_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400156- (void)writeInt32NoTag:(int32_t)value;
157
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500158/// Write a uint32_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400159- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500160/// Write a packaged array of uint32_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400161- (void)writeUInt32Array:(int32_t)fieldNumber
162 values:(GPBUInt32Array *)values
163 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500164/// Write a uint32_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400165- (void)writeUInt32NoTag:(uint32_t)value;
166
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500167/// Write a uint64_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400168- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500169/// Write a packaged array of uint64_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400170- (void)writeFixed64Array:(int32_t)fieldNumber
171 values:(GPBUInt64Array *)values
172 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500173/// Write a uint64_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400174- (void)writeFixed64NoTag:(uint64_t)value;
175
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500176/// Write a uint32_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400177- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500178/// Write a packaged array of uint32_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400179- (void)writeFixed32Array:(int32_t)fieldNumber
180 values:(GPBUInt32Array *)values
181 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500182/// Write a uint32_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400183- (void)writeFixed32NoTag:(uint32_t)value;
184
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500185/// Write a int32_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400186- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500187/// Write a packaged array of int32_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400188- (void)writeSInt32Array:(int32_t)fieldNumber
189 values:(GPBInt32Array *)values
190 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500191/// Write a int32_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400192- (void)writeSInt32NoTag:(int32_t)value;
193
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500194/// Write a int64_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400195- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500196/// Write a packaged array of int64_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400197- (void)writeSInt64Array:(int32_t)fieldNumber
198 values:(GPBInt64Array *)values
199 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500200/// Write a int64_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400201- (void)writeSInt64NoTag:(int64_t)value;
202
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500203/// Write a int64_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400204- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500205/// Write a packaged array of int64_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400206- (void)writeSFixed64Array:(int32_t)fieldNumber
207 values:(GPBInt64Array *)values
208 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500209/// Write a int64_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400210- (void)writeSFixed64NoTag:(int64_t)value;
211
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500212/// Write a int32_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400213- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500214/// Write a packaged array of int32_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400215- (void)writeSFixed32Array:(int32_t)fieldNumber
216 values:(GPBInt32Array *)values
217 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500218/// Write a int32_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400219- (void)writeSFixed32NoTag:(int32_t)value;
220
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500221/// Write a BOOL for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400222- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500223/// Write a packaged array of BOOL for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400224- (void)writeBoolArray:(int32_t)fieldNumber
225 values:(GPBBoolArray *)values
226 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500227/// Write a BOOL without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400228- (void)writeBoolNoTag:(BOOL)value;
229
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500230/// Write a int32_t for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400231- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500232/// Write a packaged array of int32_t for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400233- (void)writeEnumArray:(int32_t)fieldNumber
234 values:(GPBEnumArray *)values
235 tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500236/// Write a int32_t without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400237- (void)writeEnumNoTag:(int32_t)value;
238
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500239/// Write a NSString for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400240- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500241/// Write an array of NSString for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500242- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500243/// Write a NSString without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400244- (void)writeStringNoTag:(NSString *)value;
245
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500246/// Write a GPBMessage for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400247- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500248/// Write an array of GPBMessage for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500249- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500250/// Write a GPBMessage without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400251- (void)writeMessageNoTag:(GPBMessage *)value;
252
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500253/// Write a NSData for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400254- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500255/// Write an array of NSData for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500256- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500257/// Write a NSData without any tag.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400258- (void)writeBytesNoTag:(NSData *)value;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400259
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500260/// Write a GPBMessage for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400261- (void)writeGroup:(int32_t)fieldNumber
262 value:(GPBMessage *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500263/// Write an array of GPBMessage for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500264- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500265/// Write a GPBMessage without any tag (but does write the endGroup tag).
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400266- (void)writeGroupNoTag:(int32_t)fieldNumber
267 value:(GPBMessage *)value;
268
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500269/// Write a GPBUnknownFieldSet for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400270- (void)writeUnknownGroup:(int32_t)fieldNumber
271 value:(GPBUnknownFieldSet *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500272/// Write an array of GPBUnknownFieldSet for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500273- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500274/// Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400275- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
276 value:(GPBUnknownFieldSet *)value;
277
278//%PDDM-EXPAND-END _WRITE_DECLS()
279
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500280/// Write a MessageSet extension field to the stream. For historical reasons,
281/// the wire format differs from normal fields.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400282- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
283
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500284/// Write an unparsed MessageSet extension field to the stream. For
285/// historical reasons, the wire format differs from normal fields.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400286- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
287
288@end
289
Thomas Van Lenten8c889572015-06-16 16:45:14 -0400290NS_ASSUME_NONNULL_END
291
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400292// Write methods for types that can be in packed arrays.
293//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500294//%/// Write a TYPE for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400295//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500296//%/// Write a packaged array of TYPE for the given field number.
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400297//%- (void)write##NAME##Array:(int32_t)fieldNumber
298//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
299//% NAME$S tag:(uint32_t)tag;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500300//%/// Write a TYPE without any tag.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400301//%- (void)write##NAME##NoTag:(TYPE)value;
302//%
303// Write methods for types that aren't in packed arrays.
304//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500305//%/// Write a TYPE for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500306//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500307//%/// Write an array of TYPE for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500308//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500309//%/// Write a TYPE without any tag.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500310//%- (void)write##NAME##NoTag:(TYPE *)value;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400311//%
312// Special write methods for Groups.
313//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500314//%/// Write a TYPE for the given field number.
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400315//%- (void)write##NAME:(int32_t)fieldNumber
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500316//% NAME$S value:(TYPE *)value;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500317//%/// Write an array of TYPE for the given field number.
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500318//%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
Thomas Van Lenten36650a02016-03-07 12:07:03 -0500319//%/// Write a TYPE without any tag (but does write the endGroup tag).
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400320//%- (void)write##NAME##NoTag:(int32_t)fieldNumber
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500321//% NAME$S value:(TYPE *)value;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400322//%
323
324// One macro to hide it all up above.
325//%PDDM-DEFINE _WRITE_DECLS()
326//%_WRITE_PACKABLE_DECLS(Double, Double, double)
327//%_WRITE_PACKABLE_DECLS(Float, Float, float)
328//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
329//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
330//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
331//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
332//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
333//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
334//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
335//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
336//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
337//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
338//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
339//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500340//%_WRITE_UNPACKABLE_DECLS(String, NSString)
341//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
342//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
343//%_WRITE_GROUP_DECLS(Group, GPBMessage)
344//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)