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 33 #import "GPBBootstrap.h" 34 35 @class GPBEnumDescriptor; 36 @class GPBMessage; 37 @class GPBInt32Array; 38 39 /** 40 * Verifies that a given value can be represented by an enum type. 41 * */ 42 typedef BOOL (*GPBEnumValidationFunc)(int32_t); 43 44 /** 45 * Fetches an EnumDescriptor. 46 * */ 47 typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void); 48 49 /** 50 * Magic value used at runtime to indicate an enum value that wasn't know at 51 * compile time. 52 * */ 53 enum { 54 kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF, 55 }; 56 57 /** 58 * A union for storing all possible Protobuf values. Note that owner is 59 * responsible for memory management of object types. 60 * */ 61 typedef union { 62 BOOL valueBool; 63 int32_t valueInt32; 64 int64_t valueInt64; 65 uint32_t valueUInt32; 66 uint64_t valueUInt64; 67 float valueFloat; 68 double valueDouble; 69 GPB_UNSAFE_UNRETAINED NSData *valueData; 70 GPB_UNSAFE_UNRETAINED NSString *valueString; 71 GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage; 72 int32_t valueEnum; 73 } GPBGenericValue; 74 75 /** 76 * Enum listing the possible data types that a field can contain. 77 * 78 * @note Do not change the order of this enum (or add things to it) without 79 * thinking about it very carefully. There are several things that depend 80 * on the order. 81 * */ 82 typedef NS_ENUM(uint8_t, GPBDataType) { 83 /** Field contains boolean value(s). */ 84 GPBDataTypeBool = 0, 85 /** Field contains unsigned 4 byte value(s). */ 86 GPBDataTypeFixed32, 87 /** Field contains signed 4 byte value(s). */ 88 GPBDataTypeSFixed32, 89 /** Field contains float value(s). */ 90 GPBDataTypeFloat, 91 /** Field contains unsigned 8 byte value(s). */ 92 GPBDataTypeFixed64, 93 /** Field contains signed 8 byte value(s). */ 94 GPBDataTypeSFixed64, 95 /** Field contains double value(s). */ 96 GPBDataTypeDouble, 97 /** 98 * Field contains variable length value(s). Inefficient for encoding negative 99 * numbers – if your field is likely to have negative values, use 100 * GPBDataTypeSInt32 instead. 101 **/ 102 GPBDataTypeInt32, 103 /** 104 * Field contains variable length value(s). Inefficient for encoding negative 105 * numbers – if your field is likely to have negative values, use 106 * GPBDataTypeSInt64 instead. 107 **/ 108 GPBDataTypeInt64, 109 /** Field contains signed variable length integer value(s). */ 110 GPBDataTypeSInt32, 111 /** Field contains signed variable length integer value(s). */ 112 GPBDataTypeSInt64, 113 /** Field contains unsigned variable length integer value(s). */ 114 GPBDataTypeUInt32, 115 /** Field contains unsigned variable length integer value(s). */ 116 GPBDataTypeUInt64, 117 /** Field contains an arbitrary sequence of bytes. */ 118 GPBDataTypeBytes, 119 /** Field contains UTF-8 encoded or 7-bit ASCII text. */ 120 GPBDataTypeString, 121 /** Field contains message type(s). */ 122 GPBDataTypeMessage, 123 /** Field contains message type(s). */ 124 GPBDataTypeGroup, 125 /** Field contains enum value(s). */ 126 GPBDataTypeEnum, 127 }; 128 129 enum { 130 /** 131 * A count of the number of types in GPBDataType. Separated out from the 132 * GPBDataType enum to avoid warnings regarding not handling GPBDataType_Count 133 * in switch statements. 134 **/ 135 GPBDataType_Count = GPBDataTypeEnum + 1 136 }; 137 138 /** An extension range. */ 139 typedef struct GPBExtensionRange { 140 /** Inclusive. */ 141 uint32_t start; 142 /** Exclusive. */ 143 uint32_t end; 144 } GPBExtensionRange; 145