OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 18 matching lines...) Expand all Loading... |
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 #import <Foundation/Foundation.h> | 31 #import <Foundation/Foundation.h> |
32 | 32 |
33 #import "GPBBootstrap.h" | 33 #import "GPBBootstrap.h" |
34 | 34 |
35 @class GPBEnumDescriptor; | 35 @class GPBEnumDescriptor; |
36 @class GPBMessage; | 36 @class GPBMessage; |
37 @class GPBInt32Array; | 37 @class GPBInt32Array; |
38 | 38 |
39 /** | 39 // Function used to verify that a given value can be represented by an |
40 * Verifies that a given value can be represented by an enum type. | 40 // enum type. |
41 * */ | |
42 typedef BOOL (*GPBEnumValidationFunc)(int32_t); | 41 typedef BOOL (*GPBEnumValidationFunc)(int32_t); |
43 | 42 |
44 /** | 43 // Function used to fetch an EnumDescriptor. |
45 * Fetches an EnumDescriptor. | |
46 * */ | |
47 typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void); | 44 typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void); |
48 | 45 |
49 /** | 46 // Magic values used for when an the at runtime to indicate an enum value |
50 * Magic value used at runtime to indicate an enum value that wasn't know at | 47 // that wasn't know at compile time. |
51 * compile time. | |
52 * */ | |
53 enum { | 48 enum { |
54 kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF, | 49 kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF, |
55 }; | 50 }; |
56 | 51 |
57 /** | 52 // A union for storing all possible Protobuf values. |
58 * A union for storing all possible Protobuf values. Note that owner is | 53 // Note that owner is responsible for memory management of object types. |
59 * responsible for memory management of object types. | |
60 * */ | |
61 typedef union { | 54 typedef union { |
62 BOOL valueBool; | 55 BOOL valueBool; |
63 int32_t valueInt32; | 56 int32_t valueInt32; |
64 int64_t valueInt64; | 57 int64_t valueInt64; |
65 uint32_t valueUInt32; | 58 uint32_t valueUInt32; |
66 uint64_t valueUInt64; | 59 uint64_t valueUInt64; |
67 float valueFloat; | 60 float valueFloat; |
68 double valueDouble; | 61 double valueDouble; |
69 GPB_UNSAFE_UNRETAINED NSData *valueData; | 62 GPB_UNSAFE_UNRETAINED NSData *valueData; |
70 GPB_UNSAFE_UNRETAINED NSString *valueString; | 63 GPB_UNSAFE_UNRETAINED NSString *valueString; |
71 GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage; | 64 GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage; |
72 int32_t valueEnum; | 65 int32_t valueEnum; |
73 } GPBGenericValue; | 66 } GPBGenericValue; |
74 | 67 |
75 /** | 68 // Do not change the order of this enum (or add things to it) without thinking |
76 * Enum listing the possible data types that a field can contain. | 69 // about it very carefully. There are several things that depend on the order. |
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) { | 70 typedef NS_ENUM(uint8_t, GPBDataType) { |
83 /** Field contains boolean value(s). */ | |
84 GPBDataTypeBool = 0, | 71 GPBDataTypeBool = 0, |
85 /** Field contains unsigned 4 byte value(s). */ | |
86 GPBDataTypeFixed32, | 72 GPBDataTypeFixed32, |
87 /** Field contains signed 4 byte value(s). */ | |
88 GPBDataTypeSFixed32, | 73 GPBDataTypeSFixed32, |
89 /** Field contains float value(s). */ | |
90 GPBDataTypeFloat, | 74 GPBDataTypeFloat, |
91 /** Field contains unsigned 8 byte value(s). */ | |
92 GPBDataTypeFixed64, | 75 GPBDataTypeFixed64, |
93 /** Field contains signed 8 byte value(s). */ | |
94 GPBDataTypeSFixed64, | 76 GPBDataTypeSFixed64, |
95 /** Field contains double value(s). */ | |
96 GPBDataTypeDouble, | 77 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, | 78 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, | 79 GPBDataTypeInt64, |
109 /** Field contains signed variable length integer value(s). */ | |
110 GPBDataTypeSInt32, | 80 GPBDataTypeSInt32, |
111 /** Field contains signed variable length integer value(s). */ | |
112 GPBDataTypeSInt64, | 81 GPBDataTypeSInt64, |
113 /** Field contains unsigned variable length integer value(s). */ | |
114 GPBDataTypeUInt32, | 82 GPBDataTypeUInt32, |
115 /** Field contains unsigned variable length integer value(s). */ | |
116 GPBDataTypeUInt64, | 83 GPBDataTypeUInt64, |
117 /** Field contains an arbitrary sequence of bytes. */ | |
118 GPBDataTypeBytes, | 84 GPBDataTypeBytes, |
119 /** Field contains UTF-8 encoded or 7-bit ASCII text. */ | |
120 GPBDataTypeString, | 85 GPBDataTypeString, |
121 /** Field contains message type(s). */ | |
122 GPBDataTypeMessage, | 86 GPBDataTypeMessage, |
123 /** Field contains message type(s). */ | |
124 GPBDataTypeGroup, | 87 GPBDataTypeGroup, |
125 /** Field contains enum value(s). */ | |
126 GPBDataTypeEnum, | 88 GPBDataTypeEnum, |
127 }; | 89 }; |
128 | 90 |
129 enum { | 91 enum { |
130 /** | 92 // A count of the number of types in GPBDataType. Separated out from the |
131 * A count of the number of types in GPBDataType. Separated out from the | 93 // GPBDataType enum to avoid warnings regarding not handling |
132 * GPBDataType enum to avoid warnings regarding not handling GPBDataType_Count | 94 // GPBDataType_Count in switch statements. |
133 * in switch statements. | |
134 **/ | |
135 GPBDataType_Count = GPBDataTypeEnum + 1 | 95 GPBDataType_Count = GPBDataTypeEnum + 1 |
136 }; | 96 }; |
137 | 97 |
138 /** An extension range. */ | 98 // An extension range. |
139 typedef struct GPBExtensionRange { | 99 typedef struct GPBExtensionRange { |
140 /** Inclusive. */ | 100 uint32_t start; // inclusive |
141 uint32_t start; | 101 uint32_t end; // exclusive |
142 /** Exclusive. */ | |
143 uint32_t end; | |
144 } GPBExtensionRange; | 102 } GPBExtensionRange; |
OLD | NEW |