1b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Protocol Buffers - Google's data interchange format 2b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Copyright 2016 Google Inc. All rights reserved. 3b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// https://developers.google.com/protocol-buffers/ 4b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// 5b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Redistribution and use in source and binary forms, with or without 6b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// modification, are permitted provided that the following conditions are 7b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// met: 8b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// 9b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// * Redistributions of source code must retain the above copyright 10b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// notice, this list of conditions and the following disclaimer. 11b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// * Redistributions in binary form must reproduce the above 12b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// copyright notice, this list of conditions and the following disclaimer 13b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// in the documentation and/or other materials provided with the 14b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// distribution. 15b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// * Neither the name of Google Inc. nor the names of its 16b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// contributors may be used to endorse or promote products derived from 17b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// this software without specific prior written permission. 18b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// 19b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 31b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer#import "GPBCodedOutputStream.h" 32b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 33b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas BerghammerNS_ASSUME_NONNULL_BEGIN 34b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 35b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas BerghammerCF_EXTERN_C_BEGIN 36b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 37b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeDoubleSize(int32_t fieldNumber, double value) 38b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 39b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeFloatSize(int32_t fieldNumber, float value) 40b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 41b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeUInt64Size(int32_t fieldNumber, uint64_t value) 42b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 43b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeInt64Size(int32_t fieldNumber, int64_t value) 44b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 45b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeInt32Size(int32_t fieldNumber, int32_t value) 46b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 47b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeFixed64Size(int32_t fieldNumber, uint64_t value) 48b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 49b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeFixed32Size(int32_t fieldNumber, uint32_t value) 50b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 51b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeBoolSize(int32_t fieldNumber, BOOL value) 52b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 53b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeStringSize(int32_t fieldNumber, NSString *value) 54b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 55b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeGroupSize(int32_t fieldNumber, GPBMessage *value) 56b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 57b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeUnknownGroupSize(int32_t fieldNumber, 58b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer GPBUnknownFieldSet *value) 59b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 60b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeMessageSize(int32_t fieldNumber, GPBMessage *value) 61b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 62b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeBytesSize(int32_t fieldNumber, NSData *value) 63b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 64b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeUInt32Size(int32_t fieldNumber, uint32_t value) 65b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 66b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSFixed32Size(int32_t fieldNumber, int32_t value) 67b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 68b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSFixed64Size(int32_t fieldNumber, int64_t value) 69b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 70b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSInt32Size(int32_t fieldNumber, int32_t value) 71b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 72b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSInt64Size(int32_t fieldNumber, int64_t value) 73b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 74b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeTagSize(int32_t fieldNumber) __attribute__((const)); 75b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeWireFormatTagSize(int field_number, GPBDataType dataType) 76b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 77b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 78b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeDoubleSizeNoTag(double value) __attribute__((const)); 79b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeFloatSizeNoTag(float value) __attribute__((const)); 80b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeUInt64SizeNoTag(uint64_t value) __attribute__((const)); 81b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeInt64SizeNoTag(int64_t value) __attribute__((const)); 82b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeInt32SizeNoTag(int32_t value) __attribute__((const)); 83b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeFixed64SizeNoTag(uint64_t value) __attribute__((const)); 84b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeFixed32SizeNoTag(uint32_t value) __attribute__((const)); 85b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeBoolSizeNoTag(BOOL value) __attribute__((const)); 86b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeStringSizeNoTag(NSString *value) __attribute__((const)); 87b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeGroupSizeNoTag(GPBMessage *value) __attribute__((const)); 88b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeUnknownGroupSizeNoTag(GPBUnknownFieldSet *value) 89b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 90b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeMessageSizeNoTag(GPBMessage *value) __attribute__((const)); 91b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeBytesSizeNoTag(NSData *value) __attribute__((const)); 92b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeUInt32SizeNoTag(int32_t value) __attribute__((const)); 93b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeEnumSizeNoTag(int32_t value) __attribute__((const)); 94b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSFixed32SizeNoTag(int32_t value) __attribute__((const)); 95b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSFixed64SizeNoTag(int64_t value) __attribute__((const)); 96b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSInt32SizeNoTag(int32_t value) __attribute__((const)); 97b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSInt64SizeNoTag(int64_t value) __attribute__((const)); 98b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 99b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Note that this will calculate the size of 64 bit values truncated to 32. 100b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeSizeTSizeAsInt32NoTag(size_t value) __attribute__((const)); 101b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 102b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeRawVarint32Size(int32_t value) __attribute__((const)); 103b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeRawVarint64Size(int64_t value) __attribute__((const)); 104b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 105b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Note that this will calculate the size of 64 bit values truncated to 32. 106b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeRawVarint32SizeForInteger(NSInteger value) 107b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 108b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 109b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Compute the number of bytes that would be needed to encode a 110b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// MessageSet extension to the stream. For historical reasons, 111b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// the wire format differs from normal fields. 112b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeMessageSetExtensionSize(int32_t fieldNumber, GPBMessage *value) 113b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 114b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 115b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// Compute the number of bytes that would be needed to encode an 116b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// unparsed MessageSet extension field to the stream. For 117b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer// historical reasons, the wire format differs from normal fields. 118b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeRawMessageSetExtensionSize(int32_t fieldNumber, NSData *value) 119b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 120b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 121b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammersize_t GPBComputeEnumSize(int32_t fieldNumber, int32_t value) 122b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer __attribute__((const)); 123b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 124b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas BerghammerCF_EXTERN_C_END 125b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas Berghammer 126b0575e93e4c39dec69365b850088a1eb7f82c5b3Tamas BerghammerNS_ASSUME_NONNULL_END 127