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