1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
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
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.
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.
31 #import <Foundation/Foundation.h>
33 #import "GPBBootstrap.h"
35 @class GPBEnumDescriptor;
40 * Verifies that a given value can be represented by an enum type.
42 typedef BOOL (*GPBEnumValidationFunc)(int32_t);
45 * Fetches an EnumDescriptor.
47 typedef GPBEnumDescriptor *(*GPBEnumDescriptorFunc)(void);
50 * Magic value used at runtime to indicate an enum value that wasn't know at
54 kGPBUnrecognizedEnumeratorValue = (int32_t)0xFBADBEEF,
58 * A union for storing all possible Protobuf values. Note that owner is
59 * responsible for memory management of object types.
69 GPB_UNSAFE_UNRETAINED NSData *valueData;
70 GPB_UNSAFE_UNRETAINED NSString *valueString;
71 GPB_UNSAFE_UNRETAINED GPBMessage *valueMessage;
76 * Enum listing the possible data types that a field can contain.
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
82 typedef NS_ENUM(uint8_t, GPBDataType) {
83 /** Field contains boolean value(s). */
85 /** Field contains unsigned 4 byte value(s). */
87 /** Field contains signed 4 byte value(s). */
89 /** Field contains float value(s). */
91 /** Field contains unsigned 8 byte value(s). */
93 /** Field contains signed 8 byte value(s). */
95 /** Field contains double value(s). */
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.
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.
109 /** Field contains signed variable length integer value(s). */
111 /** Field contains signed variable length integer value(s). */
113 /** Field contains unsigned variable length integer value(s). */
115 /** Field contains unsigned variable length integer value(s). */
117 /** Field contains an arbitrary sequence of bytes. */
119 /** Field contains UTF-8 encoded or 7-bit ASCII text. */
121 /** Field contains message type(s). */
123 /** Field contains message type(s). */
125 /** Field contains enum value(s). */
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.
135 GPBDataType_Count = GPBDataTypeEnum + 1
138 /** An extension range. */
139 typedef struct GPBExtensionRange {