Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 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 | |
| 31 | #import <Foundation/Foundation.h> |
| 32 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 33 | #import "GPBRuntimeTypes.h" |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 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 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 47 | NS_ASSUME_NONNULL_BEGIN |
| 48 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 49 | /// 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 Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 56 | @interface GPBCodedOutputStream : NSObject |
| 57 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 58 | /// 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 Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 60 | + (instancetype)streamWithData:(NSMutableData *)data; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 61 | |
| 62 | /// Creates a stream to write into the given @c NSOutputStream. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 63 | + (instancetype)streamWithOutputStream:(NSOutputStream *)output; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 64 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 65 | /// 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 Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 67 | - (instancetype)initWithData:(NSMutableData *)data; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 68 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 69 | /// Initializes a stream to write into the given @c NSOutputStream. |
| 70 | - (instancetype)initWithOutputStream:(NSOutputStream *)output; |
| 71 | |
| 72 | /// Flush any buffered data out. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 73 | - (void)flush; |
| 74 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 75 | /// Write the raw byte out. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 76 | - (void)writeRawByte:(uint8_t)value; |
| 77 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 78 | /// 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 Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 82 | - (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format; |
| 83 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 84 | /// Write a 32bit value out in little endian format. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 85 | - (void)writeRawLittleEndian32:(int32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 86 | /// Write a 64bit value out in little endian format. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 87 | - (void)writeRawLittleEndian64:(int64_t)value; |
| 88 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 89 | /// Write a 32bit value out in varint format. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 90 | - (void)writeRawVarint32:(int32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 91 | /// Write a 64bit value out in varint format. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 92 | - (void)writeRawVarint64:(int64_t)value; |
| 93 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 94 | /// Write a size_t out as a 32bit varint value. |
| 95 | /// |
| 96 | /// @note This will truncate 64 bit values to 32. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 97 | - (void)writeRawVarintSizeTAs32:(size_t)value; |
| 98 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 99 | /// Writes the contents of an @c NSData out. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 100 | - (void)writeRawData:(NSData *)data; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 101 | /// 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 Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 106 | - (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 Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 113 | /// Write a double for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 114 | - (void)writeDouble:(int32_t)fieldNumber value:(double)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 115 | /// Write a packaged array of double for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 116 | - (void)writeDoubleArray:(int32_t)fieldNumber |
| 117 | values:(GPBDoubleArray *)values |
| 118 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 119 | /// Write a double without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 120 | - (void)writeDoubleNoTag:(double)value; |
| 121 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 122 | /// Write a float for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 123 | - (void)writeFloat:(int32_t)fieldNumber value:(float)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 124 | /// Write a packaged array of float for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 125 | - (void)writeFloatArray:(int32_t)fieldNumber |
| 126 | values:(GPBFloatArray *)values |
| 127 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 128 | /// Write a float without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 129 | - (void)writeFloatNoTag:(float)value; |
| 130 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 131 | /// Write a uint64_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 132 | - (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 133 | /// Write a packaged array of uint64_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 134 | - (void)writeUInt64Array:(int32_t)fieldNumber |
| 135 | values:(GPBUInt64Array *)values |
| 136 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 137 | /// Write a uint64_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 138 | - (void)writeUInt64NoTag:(uint64_t)value; |
| 139 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 140 | /// Write a int64_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 141 | - (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 142 | /// Write a packaged array of int64_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 143 | - (void)writeInt64Array:(int32_t)fieldNumber |
| 144 | values:(GPBInt64Array *)values |
| 145 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 146 | /// Write a int64_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 147 | - (void)writeInt64NoTag:(int64_t)value; |
| 148 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 149 | /// Write a int32_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 150 | - (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 151 | /// Write a packaged array of int32_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 152 | - (void)writeInt32Array:(int32_t)fieldNumber |
| 153 | values:(GPBInt32Array *)values |
| 154 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 155 | /// Write a int32_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 156 | - (void)writeInt32NoTag:(int32_t)value; |
| 157 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 158 | /// Write a uint32_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 159 | - (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 160 | /// Write a packaged array of uint32_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 161 | - (void)writeUInt32Array:(int32_t)fieldNumber |
| 162 | values:(GPBUInt32Array *)values |
| 163 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 164 | /// Write a uint32_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 165 | - (void)writeUInt32NoTag:(uint32_t)value; |
| 166 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 167 | /// Write a uint64_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 168 | - (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 169 | /// Write a packaged array of uint64_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 170 | - (void)writeFixed64Array:(int32_t)fieldNumber |
| 171 | values:(GPBUInt64Array *)values |
| 172 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 173 | /// Write a uint64_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 174 | - (void)writeFixed64NoTag:(uint64_t)value; |
| 175 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 176 | /// Write a uint32_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 177 | - (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 178 | /// Write a packaged array of uint32_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 179 | - (void)writeFixed32Array:(int32_t)fieldNumber |
| 180 | values:(GPBUInt32Array *)values |
| 181 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 182 | /// Write a uint32_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 183 | - (void)writeFixed32NoTag:(uint32_t)value; |
| 184 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 185 | /// Write a int32_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 186 | - (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 187 | /// Write a packaged array of int32_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 188 | - (void)writeSInt32Array:(int32_t)fieldNumber |
| 189 | values:(GPBInt32Array *)values |
| 190 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 191 | /// Write a int32_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 192 | - (void)writeSInt32NoTag:(int32_t)value; |
| 193 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 194 | /// Write a int64_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 195 | - (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 196 | /// Write a packaged array of int64_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 197 | - (void)writeSInt64Array:(int32_t)fieldNumber |
| 198 | values:(GPBInt64Array *)values |
| 199 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 200 | /// Write a int64_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 201 | - (void)writeSInt64NoTag:(int64_t)value; |
| 202 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 203 | /// Write a int64_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 204 | - (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 205 | /// Write a packaged array of int64_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 206 | - (void)writeSFixed64Array:(int32_t)fieldNumber |
| 207 | values:(GPBInt64Array *)values |
| 208 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 209 | /// Write a int64_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 210 | - (void)writeSFixed64NoTag:(int64_t)value; |
| 211 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 212 | /// Write a int32_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 213 | - (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 214 | /// Write a packaged array of int32_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 215 | - (void)writeSFixed32Array:(int32_t)fieldNumber |
| 216 | values:(GPBInt32Array *)values |
| 217 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 218 | /// Write a int32_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 219 | - (void)writeSFixed32NoTag:(int32_t)value; |
| 220 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 221 | /// Write a BOOL for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 222 | - (void)writeBool:(int32_t)fieldNumber value:(BOOL)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 223 | /// Write a packaged array of BOOL for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 224 | - (void)writeBoolArray:(int32_t)fieldNumber |
| 225 | values:(GPBBoolArray *)values |
| 226 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 227 | /// Write a BOOL without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 228 | - (void)writeBoolNoTag:(BOOL)value; |
| 229 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 230 | /// Write a int32_t for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 231 | - (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 232 | /// Write a packaged array of int32_t for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 233 | - (void)writeEnumArray:(int32_t)fieldNumber |
| 234 | values:(GPBEnumArray *)values |
| 235 | tag:(uint32_t)tag; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 236 | /// Write a int32_t without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 237 | - (void)writeEnumNoTag:(int32_t)value; |
| 238 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 239 | /// Write a NSString for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 240 | - (void)writeString:(int32_t)fieldNumber value:(NSString *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 241 | /// Write an array of NSString for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 242 | - (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 243 | /// Write a NSString without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 244 | - (void)writeStringNoTag:(NSString *)value; |
| 245 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 246 | /// Write a GPBMessage for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 247 | - (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 248 | /// Write an array of GPBMessage for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 249 | - (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 250 | /// Write a GPBMessage without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 251 | - (void)writeMessageNoTag:(GPBMessage *)value; |
| 252 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 253 | /// Write a NSData for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 254 | - (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 255 | /// Write an array of NSData for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 256 | - (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 257 | /// Write a NSData without any tag. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 258 | - (void)writeBytesNoTag:(NSData *)value; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 259 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 260 | /// Write a GPBMessage for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 261 | - (void)writeGroup:(int32_t)fieldNumber |
| 262 | value:(GPBMessage *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 263 | /// Write an array of GPBMessage for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 264 | - (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 265 | /// Write a GPBMessage without any tag (but does write the endGroup tag). |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 266 | - (void)writeGroupNoTag:(int32_t)fieldNumber |
| 267 | value:(GPBMessage *)value; |
| 268 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 269 | /// Write a GPBUnknownFieldSet for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 270 | - (void)writeUnknownGroup:(int32_t)fieldNumber |
| 271 | value:(GPBUnknownFieldSet *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 272 | /// Write an array of GPBUnknownFieldSet for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 273 | - (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 274 | /// Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag). |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 275 | - (void)writeUnknownGroupNoTag:(int32_t)fieldNumber |
| 276 | value:(GPBUnknownFieldSet *)value; |
| 277 | |
| 278 | //%PDDM-EXPAND-END _WRITE_DECLS() |
| 279 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 280 | /// Write a MessageSet extension field to the stream. For historical reasons, |
| 281 | /// the wire format differs from normal fields. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 282 | - (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value; |
| 283 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 284 | /// Write an unparsed MessageSet extension field to the stream. For |
| 285 | /// historical reasons, the wire format differs from normal fields. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 286 | - (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value; |
| 287 | |
| 288 | @end |
| 289 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 290 | NS_ASSUME_NONNULL_END |
| 291 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 292 | // Write methods for types that can be in packed arrays. |
| 293 | //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE) |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 294 | //%/// Write a TYPE for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 295 | //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 296 | //%/// Write a packaged array of TYPE for the given field number. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 297 | //%- (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 Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 300 | //%/// Write a TYPE without any tag. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 301 | //%- (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 Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 305 | //%/// Write a TYPE for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 306 | //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 307 | //%/// Write an array of TYPE for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 308 | //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 309 | //%/// Write a TYPE without any tag. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 310 | //%- (void)write##NAME##NoTag:(TYPE *)value; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 311 | //% |
| 312 | // Special write methods for Groups. |
| 313 | //%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE) |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 314 | //%/// Write a TYPE for the given field number. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 315 | //%- (void)write##NAME:(int32_t)fieldNumber |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 316 | //% NAME$S value:(TYPE *)value; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 317 | //%/// Write an array of TYPE for the given field number. |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 318 | //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values; |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 319 | //%/// Write a TYPE without any tag (but does write the endGroup tag). |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 320 | //%- (void)write##NAME##NoTag:(int32_t)fieldNumber |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 321 | //% NAME$S value:(TYPE *)value; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 322 | //% |
| 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 Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 340 | //%_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) |