| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 | // Protocol Buffers - Google's data interchange format// Copyright 2008 Google Inc.  All rights reserved.// https://developers.google.com/protocol-buffers///// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are// met:////     * Redistributions of source code must retain the above copyright// notice, this list of conditions and the following disclaimer.//     * Redistributions in binary form must reproduce the above// copyright notice, this list of conditions and the following disclaimer// in the documentation and/or other materials provided with the// distribution.//     * Neither the name of Google Inc. nor the names of its// contributors may be used to endorse or promote products derived from// this software without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#import <Foundation/Foundation.h>#import "GPBRuntimeTypes.h"#import "GPBWireFormat.h"@class GPBBoolArray;@class GPBDoubleArray;@class GPBEnumArray;@class GPBFloatArray;@class GPBMessage;@class GPBInt32Array;@class GPBInt64Array;@class GPBUInt32Array;@class GPBUInt64Array;@class GPBUnknownFieldSet;NS_ASSUME_NONNULL_BEGIN/** * Writes out protocol message fields. * * The common uses of protocol buffers shouldn't need to use this class. * GPBMessage's provide a -data method that will serialize the message for you. * * @note Subclassing of GPBCodedOutputStream is NOT supported. **/@interface GPBCodedOutputStream : NSObject/** * Creates a stream to fill in the given data. Data must be sized to fit or * an error will be raised when out of space. * * @param data The data where the stream will be written to. * * @return A newly instanced GPBCodedOutputStream. **/+ (instancetype)streamWithData:(NSMutableData *)data;/** * Creates a stream to write into the given NSOutputStream. * * @param output The output stream where the stream will be written to. * * @return A newly instanced GPBCodedOutputStream. **/+ (instancetype)streamWithOutputStream:(NSOutputStream *)output;/** * Initializes a stream to fill in the given data. Data must be sized to fit * or an error will be raised when out of space. * * @param data The data where the stream will be written to. * * @return A newly initialized GPBCodedOutputStream. **/- (instancetype)initWithData:(NSMutableData *)data;/** * Initializes a stream to write into the given @c NSOutputStream. * * @param output The output stream where the stream will be written to. * * @return A newly initialized GPBCodedOutputStream. **/- (instancetype)initWithOutputStream:(NSOutputStream *)output;/** * Flush any buffered data out. **/- (void)flush;/** * Write the raw byte out. * * @param value The value to write out. **/- (void)writeRawByte:(uint8_t)value;/** * Write the tag for the given field number and wire format. * * @param fieldNumber The field number. * @param format      The wire format the data for the field will be in. **/- (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;/** * Write a 32bit value out in little endian format. * * @param value The value to write out. **/- (void)writeRawLittleEndian32:(int32_t)value;/** * Write a 64bit value out in little endian format. * * @param value The value to write out. **/- (void)writeRawLittleEndian64:(int64_t)value;/** * Write a 32bit value out in varint format. * * @param value The value to write out. **/- (void)writeRawVarint32:(int32_t)value;/** * Write a 64bit value out in varint format. * * @param value The value to write out. **/- (void)writeRawVarint64:(int64_t)value;/** * Write a size_t out as a 32bit varint value. * * @note This will truncate 64 bit values to 32. * * @param value The value to write out. **/- (void)writeRawVarintSizeTAs32:(size_t)value;/** * Writes the contents of an NSData out. * * @param data The data to write out. **/- (void)writeRawData:(NSData *)data;/** * Writes out the given data. * * @param data   The data blob to write out. * @param offset The offset into the blob to start writing out. * @param length The number of bytes from the blob to write out. **/- (void)writeRawPtr:(const void *)data             offset:(size_t)offset             length:(size_t)length;//%PDDM-EXPAND _WRITE_DECLS()// This block of code is generated, do not edit it directly./** * Write a double for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeDouble:(int32_t)fieldNumber value:(double)value;/** * Write a packed array of double for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeDoubleArray:(int32_t)fieldNumber                  values:(GPBDoubleArray *)values                     tag:(uint32_t)tag;/** * Write a double without any tag. * * @param value The value to write out. **/- (void)writeDoubleNoTag:(double)value;/** * Write a float for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeFloat:(int32_t)fieldNumber value:(float)value;/** * Write a packed array of float for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeFloatArray:(int32_t)fieldNumber                 values:(GPBFloatArray *)values                    tag:(uint32_t)tag;/** * Write a float without any tag. * * @param value The value to write out. **/- (void)writeFloatNoTag:(float)value;/** * Write a uint64_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;/** * Write a packed array of uint64_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeUInt64Array:(int32_t)fieldNumber                  values:(GPBUInt64Array *)values                     tag:(uint32_t)tag;/** * Write a uint64_t without any tag. * * @param value The value to write out. **/- (void)writeUInt64NoTag:(uint64_t)value;/** * Write a int64_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;/** * Write a packed array of int64_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeInt64Array:(int32_t)fieldNumber                 values:(GPBInt64Array *)values                    tag:(uint32_t)tag;/** * Write a int64_t without any tag. * * @param value The value to write out. **/- (void)writeInt64NoTag:(int64_t)value;/** * Write a int32_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;/** * Write a packed array of int32_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeInt32Array:(int32_t)fieldNumber                 values:(GPBInt32Array *)values                    tag:(uint32_t)tag;/** * Write a int32_t without any tag. * * @param value The value to write out. **/- (void)writeInt32NoTag:(int32_t)value;/** * Write a uint32_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;/** * Write a packed array of uint32_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeUInt32Array:(int32_t)fieldNumber                  values:(GPBUInt32Array *)values                     tag:(uint32_t)tag;/** * Write a uint32_t without any tag. * * @param value The value to write out. **/- (void)writeUInt32NoTag:(uint32_t)value;/** * Write a uint64_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;/** * Write a packed array of uint64_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeFixed64Array:(int32_t)fieldNumber                   values:(GPBUInt64Array *)values                      tag:(uint32_t)tag;/** * Write a uint64_t without any tag. * * @param value The value to write out. **/- (void)writeFixed64NoTag:(uint64_t)value;/** * Write a uint32_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;/** * Write a packed array of uint32_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeFixed32Array:(int32_t)fieldNumber                   values:(GPBUInt32Array *)values                      tag:(uint32_t)tag;/** * Write a uint32_t without any tag. * * @param value The value to write out. **/- (void)writeFixed32NoTag:(uint32_t)value;/** * Write a int32_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;/** * Write a packed array of int32_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeSInt32Array:(int32_t)fieldNumber                  values:(GPBInt32Array *)values                     tag:(uint32_t)tag;/** * Write a int32_t without any tag. * * @param value The value to write out. **/- (void)writeSInt32NoTag:(int32_t)value;/** * Write a int64_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;/** * Write a packed array of int64_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeSInt64Array:(int32_t)fieldNumber                  values:(GPBInt64Array *)values                     tag:(uint32_t)tag;/** * Write a int64_t without any tag. * * @param value The value to write out. **/- (void)writeSInt64NoTag:(int64_t)value;/** * Write a int64_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;/** * Write a packed array of int64_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeSFixed64Array:(int32_t)fieldNumber                    values:(GPBInt64Array *)values                       tag:(uint32_t)tag;/** * Write a int64_t without any tag. * * @param value The value to write out. **/- (void)writeSFixed64NoTag:(int64_t)value;/** * Write a int32_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;/** * Write a packed array of int32_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeSFixed32Array:(int32_t)fieldNumber                    values:(GPBInt32Array *)values                       tag:(uint32_t)tag;/** * Write a int32_t without any tag. * * @param value The value to write out. **/- (void)writeSFixed32NoTag:(int32_t)value;/** * Write a BOOL for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;/** * Write a packed array of BOOL for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeBoolArray:(int32_t)fieldNumber                values:(GPBBoolArray *)values                   tag:(uint32_t)tag;/** * Write a BOOL without any tag. * * @param value The value to write out. **/- (void)writeBoolNoTag:(BOOL)value;/** * Write a int32_t for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;/** * Write a packed array of int32_t for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. * @param tag         The tag assigned to the values. **/- (void)writeEnumArray:(int32_t)fieldNumber                values:(GPBEnumArray *)values                   tag:(uint32_t)tag;/** * Write a int32_t without any tag. * * @param value The value to write out. **/- (void)writeEnumNoTag:(int32_t)value;/** * Write a NSString for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeString:(int32_t)fieldNumber value:(NSString *)value;/** * Write an array of NSString for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. **/- (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;/** * Write a NSString without any tag. * * @param value The value to write out. **/- (void)writeStringNoTag:(NSString *)value;/** * Write a GPBMessage for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;/** * Write an array of GPBMessage for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. **/- (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;/** * Write a GPBMessage without any tag. * * @param value The value to write out. **/- (void)writeMessageNoTag:(GPBMessage *)value;/** * Write a NSData for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;/** * Write an array of NSData for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. **/- (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;/** * Write a NSData without any tag. * * @param value The value to write out. **/- (void)writeBytesNoTag:(NSData *)value;/** * Write a GPBMessage for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeGroup:(int32_t)fieldNumber             value:(GPBMessage *)value;/** * Write an array of GPBMessage for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. **/- (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;/** * Write a GPBMessage without any tag (but does write the endGroup tag). * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeGroupNoTag:(int32_t)fieldNumber                  value:(GPBMessage *)value;/** * Write a GPBUnknownFieldSet for the given field number. * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeUnknownGroup:(int32_t)fieldNumber                    value:(GPBUnknownFieldSet *)value;/** * Write an array of GPBUnknownFieldSet for the given field number. * * @param fieldNumber The field number assigned to the values. * @param values      The values to write out. **/- (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;/** * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag). * * @param fieldNumber The field number assigned to the value. * @param value       The value to write out. **/- (void)writeUnknownGroupNoTag:(int32_t)fieldNumber                         value:(GPBUnknownFieldSet *)value;//%PDDM-EXPAND-END _WRITE_DECLS()/**Write a MessageSet extension field to the stream. For historical reasons,the wire format differs from normal fields.@param fieldNumber The extension field number to write out.@param value       The message from where to get the extension.*/- (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;/**Write an unparsed MessageSet extension field to the stream. For historicalreasons, the wire format differs from normal fields.@param fieldNumber The extension field number to write out.@param value       The raw message from where to get the extension.*/- (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;@endNS_ASSUME_NONNULL_END// Write methods for types that can be in packed arrays.//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)//%/**//% * Write a TYPE for the given field number.//% *//% * @param fieldNumber The field number assigned to the value.//% * @param value       The value to write out.//% **///%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;//%/**//% * Write a packed array of TYPE for the given field number.//% *//% * @param fieldNumber The field number assigned to the values.//% * @param values      The values to write out.//% * @param tag         The tag assigned to the values.//% **///%- (void)write##NAME##Array:(int32_t)fieldNumber//%       NAME$S     values:(GPB##ARRAY_TYPE##Array *)values//%       NAME$S        tag:(uint32_t)tag;//%/**//% * Write a TYPE without any tag.//% *//% * @param value The value to write out.//% **///%- (void)write##NAME##NoTag:(TYPE)value;//%// Write methods for types that aren't in packed arrays.//%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)//%/**//% * Write a TYPE for the given field number.//% *//% * @param fieldNumber The field number assigned to the value.//% * @param value       The value to write out.//% **///%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;//%/**//% * Write an array of TYPE for the given field number.//% *//% * @param fieldNumber The field number assigned to the values.//% * @param values      The values to write out.//% **///%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;//%/**//% * Write a TYPE without any tag.//% *//% * @param value The value to write out.//% **///%- (void)write##NAME##NoTag:(TYPE *)value;//%// Special write methods for Groups.//%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)//%/**//% * Write a TYPE for the given field number.//% *//% * @param fieldNumber The field number assigned to the value.//% * @param value       The value to write out.//% **///%- (void)write##NAME:(int32_t)fieldNumber//%       NAME$S value:(TYPE *)value;//%/**//% * Write an array of TYPE for the given field number.//% *//% * @param fieldNumber The field number assigned to the values.//% * @param values      The values to write out.//% **///%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;//%/**//% * Write a TYPE without any tag (but does write the endGroup tag).//% *//% * @param fieldNumber The field number assigned to the value.//% * @param value       The value to write out.//% **///%- (void)write##NAME##NoTag:(int32_t)fieldNumber//%            NAME$S value:(TYPE *)value;//%// One macro to hide it all up above.//%PDDM-DEFINE _WRITE_DECLS()//%_WRITE_PACKABLE_DECLS(Double, Double, double)//%_WRITE_PACKABLE_DECLS(Float, Float, float)//%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)//%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)//%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)//%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)//%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)//%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)//%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)//%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)//%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)//%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)//%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)//%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)//%_WRITE_UNPACKABLE_DECLS(String, NSString)//%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)//%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)//%_WRITE_GROUP_DECLS(Group, GPBMessage)//%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)
 |