Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 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 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 33 | #import "GPBRuntimeTypes.h" |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 34 | |
| 35 | @class GPBEnumDescriptor; |
| 36 | @class GPBFieldDescriptor; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 37 | @class GPBFileDescriptor; |
| 38 | @class GPBOneofDescriptor; |
| 39 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 40 | NS_ASSUME_NONNULL_BEGIN |
| 41 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 42 | /** Syntax used in the proto file. */ |
Thomas Van Lenten | 79a23c4 | 2016-03-17 10:04:21 -0400 | [diff] [blame] | 43 | typedef NS_ENUM(uint8_t, GPBFileSyntax) { |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 44 | /** Unknown syntax. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 45 | GPBFileSyntaxUnknown = 0, |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 46 | /** Proto2 syntax. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 47 | GPBFileSyntaxProto2 = 2, |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 48 | /** Proto3 syntax. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 49 | GPBFileSyntaxProto3 = 3, |
| 50 | }; |
| 51 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 52 | /** Type of proto field. */ |
Thomas Van Lenten | 79a23c4 | 2016-03-17 10:04:21 -0400 | [diff] [blame] | 53 | typedef NS_ENUM(uint8_t, GPBFieldType) { |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 54 | /** Optional/required field. Only valid for proto2 fields. */ |
| 55 | GPBFieldTypeSingle, |
| 56 | /** Repeated field. */ |
| 57 | GPBFieldTypeRepeated, |
| 58 | /** Map field. */ |
| 59 | GPBFieldTypeMap, |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 60 | }; |
| 61 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 62 | /** |
| 63 | * Describes a proto message. |
| 64 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 65 | @interface GPBDescriptor : NSObject<NSCopying> |
| 66 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 67 | /** Name of the message. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 68 | @property(nonatomic, readonly, copy) NSString *name; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 69 | /** Fields declared in the message. */ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 70 | @property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 71 | /** Oneofs declared in the message. */ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 72 | @property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *oneofs; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 73 | /** Extension range declared for the message. */ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 74 | @property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 75 | /** Number of extension ranges declared for the message. */ |
Thomas Van Lenten | 79a23c4 | 2016-03-17 10:04:21 -0400 | [diff] [blame] | 76 | @property(nonatomic, readonly) uint32_t extensionRangesCount; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 77 | /** Descriptor for the file where the message was defined. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 78 | @property(nonatomic, readonly, assign) GPBFileDescriptor *file; |
| 79 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 80 | /** Whether the message is in wire format or not. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 81 | @property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 82 | /** The class of this message. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 83 | @property(nonatomic, readonly) Class messageClass; |
Thomas Van Lenten | 337ec30 | 2016-08-16 11:26:49 -0400 | [diff] [blame] | 84 | /** Containing message descriptor if this message is nested, or nil otherwise. */ |
| 85 | @property(readonly, nullable) GPBDescriptor *containingType; |
| 86 | /** |
| 87 | * Fully qualified name for this message (package.message). Can be nil if the |
| 88 | * value is unable to be computed. |
| 89 | */ |
| 90 | @property(readonly, nullable) NSString *fullName; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 91 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 92 | /** |
| 93 | * Gets the field for the given number. |
| 94 | * |
| 95 | * @param fieldNumber The number for the field to get. |
| 96 | * |
| 97 | * @return The field descriptor for the given number, or nil if not found. |
| 98 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 99 | - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * Gets the field for the given name. |
| 103 | * |
| 104 | * @param name The name for the field to get. |
| 105 | * |
| 106 | * @return The field descriptor for the given name, or nil if not found. |
| 107 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 108 | - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Gets the oneof for the given name. |
| 112 | * |
| 113 | * @param name The name for the oneof to get. |
| 114 | * |
| 115 | * @return The oneof descriptor for the given name, or nil if not found. |
| 116 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 117 | - (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 118 | |
| 119 | @end |
| 120 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 121 | /** |
| 122 | * Describes a proto file. |
| 123 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 124 | @interface GPBFileDescriptor : NSObject |
| 125 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 126 | /** The package declared in the proto file. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 127 | @property(nonatomic, readonly, copy) NSString *package; |
Thomas Van Lenten | 337ec30 | 2016-08-16 11:26:49 -0400 | [diff] [blame] | 128 | /** The objc prefix declared in the proto file. */ |
| 129 | @property(nonatomic, readonly, copy, nullable) NSString *objcPrefix; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 130 | /** The syntax of the proto file. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 131 | @property(nonatomic, readonly) GPBFileSyntax syntax; |
| 132 | |
| 133 | @end |
| 134 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 135 | /** |
| 136 | * Describes a oneof field. |
| 137 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 138 | @interface GPBOneofDescriptor : NSObject |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 139 | /** Name of the oneof field. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 140 | @property(nonatomic, readonly) NSString *name; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 141 | /** Fields declared in the oneof. */ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 142 | @property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 143 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 144 | /** |
| 145 | * Gets the field for the given number. |
| 146 | * |
| 147 | * @param fieldNumber The number for the field to get. |
| 148 | * |
| 149 | * @return The field descriptor for the given number, or nil if not found. |
| 150 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 151 | - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * Gets the field for the given name. |
| 155 | * |
| 156 | * @param name The name for the field to get. |
| 157 | * |
| 158 | * @return The field descriptor for the given name, or nil if not found. |
| 159 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 160 | - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 161 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 162 | @end |
| 163 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 164 | /** |
| 165 | * Describes a proto field. |
| 166 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 167 | @interface GPBFieldDescriptor : NSObject |
| 168 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 169 | /** Name of the field. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 170 | @property(nonatomic, readonly, copy) NSString *name; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 171 | /** Number associated with the field. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 172 | @property(nonatomic, readonly) uint32_t number; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 173 | /** Data type contained in the field. */ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 174 | @property(nonatomic, readonly) GPBDataType dataType; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 175 | /** Whether it has a default value or not. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 176 | @property(nonatomic, readonly) BOOL hasDefaultValue; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 177 | /** Default value for the field. */ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 178 | @property(nonatomic, readonly) GPBGenericValue defaultValue; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 179 | /** Whether this field is required. Only valid for proto2 fields. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 180 | @property(nonatomic, readonly, getter=isRequired) BOOL required; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 181 | /** Whether this field is optional. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 182 | @property(nonatomic, readonly, getter=isOptional) BOOL optional; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 183 | /** Type of field (single, repeated, map). */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 184 | @property(nonatomic, readonly) GPBFieldType fieldType; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 185 | /** Type of the key if the field is a map. The value's type is -fieldType. */ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 186 | @property(nonatomic, readonly) GPBDataType mapKeyDataType; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 187 | /** Whether the field is packable. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 188 | @property(nonatomic, readonly, getter=isPackable) BOOL packable; |
| 189 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 190 | /** The containing oneof if this field is part of one, nil otherwise. */ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 191 | @property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 192 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 193 | /** Class of the message if the field is of message type. */ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 194 | @property(nonatomic, readonly, assign, nullable) Class msgClass; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 195 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 196 | /** Descriptor for the enum if this field is an enum. */ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 197 | @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 198 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Checks whether the given enum raw value is a valid enum value. |
| 201 | * |
| 202 | * @param value The raw enum value to check. |
| 203 | * |
| 204 | * @return YES if value is a valid enum raw value. |
| 205 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 206 | - (BOOL)isValidEnumValue:(int32_t)value; |
| 207 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 208 | /** @return Name for the text format, or nil if not known. */ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 209 | - (nullable NSString *)textFormatName; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 210 | |
| 211 | @end |
| 212 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 213 | /** |
| 214 | * Describes a proto enum. |
| 215 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 216 | @interface GPBEnumDescriptor : NSObject |
| 217 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 218 | /** Name of the enum. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 219 | @property(nonatomic, readonly, copy) NSString *name; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 220 | /** Function that validates that raw values are valid enum values. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 221 | @property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier; |
| 222 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 223 | /** |
| 224 | * Returns the enum value name for the given raw enum. |
| 225 | * |
leovitch | 2804902 | 2018-05-29 21:08:00 +0900 | [diff] [blame] | 226 | * Note that there can be more than one name corresponding to a given value |
| 227 | * if the allow_alias option is used. |
| 228 | * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 229 | * @param number The raw enum value. |
| 230 | * |
leovitch | 2804902 | 2018-05-29 21:08:00 +0900 | [diff] [blame] | 231 | * @return The first name that matches the enum value passed, or nil if not valid. |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 232 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 233 | - (nullable NSString *)enumNameForValue:(int32_t)number; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 234 | |
| 235 | /** |
| 236 | * Gets the enum raw value for the given enum name. |
| 237 | * |
| 238 | * @param outValue A pointer where the value will be set. |
| 239 | * @param name The enum name for which to get the raw value. |
| 240 | * |
| 241 | * @return YES if a value was copied into the pointer, NO otherwise. |
| 242 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 243 | - (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 244 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 245 | /** |
| 246 | * Returns the text format for the given raw enum value. |
| 247 | * |
| 248 | * @param number The raw enum value. |
| 249 | * |
leovitch | 2804902 | 2018-05-29 21:08:00 +0900 | [diff] [blame] | 250 | * @return The first text format name which matches the enum value, or nil if not valid. |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 251 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 252 | - (nullable NSString *)textFormatNameForValue:(int32_t)number; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * Gets the enum raw value for the given text format name. |
| 256 | * |
| 257 | * @param outValue A pointer where the value will be set. |
| 258 | * @param textFormatName The text format name for which to get the raw value. |
| 259 | * |
| 260 | * @return YES if a value was copied into the pointer, NO otherwise. |
| 261 | **/ |
Dimitris Koutsogiorgas | 37ca94f | 2016-06-24 17:40:29 -0700 | [diff] [blame] | 262 | - (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 263 | |
leovitch | 2804902 | 2018-05-29 21:08:00 +0900 | [diff] [blame] | 264 | /** |
| 265 | * Gets the number of defined enum names. |
| 266 | * |
| 267 | * @return Count of the number of enum names, including any aliases. |
| 268 | */ |
| 269 | @property(nonatomic, readonly) uint32_t enumNameCount; |
| 270 | |
| 271 | /** |
| 272 | * Gets the enum name corresponding to the given index. |
| 273 | * |
| 274 | * @param index Index into the available names. The defined range is from 0 |
| 275 | * to self.enumNameCount - 1. |
| 276 | * |
| 277 | * @returns The enum name at the given index, or nil if the index is out of range. |
| 278 | */ |
| 279 | - (nullable NSString *)getEnumNameForIndex:(uint32_t)index; |
| 280 | |
| 281 | /** |
| 282 | * Gets the enum text format name corresponding to the given index. |
| 283 | * |
| 284 | * @param index Index into the available names. The defined range is from 0 |
| 285 | * to self.enumNameCount - 1. |
| 286 | * |
| 287 | * @returns The text format name at the given index, or nil if the index is out of range. |
| 288 | */ |
| 289 | - (nullable NSString *)getEnumTextFormatNameForIndex:(uint32_t)index; |
| 290 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 291 | @end |
| 292 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 293 | /** |
| 294 | * Describes a proto extension. |
| 295 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 296 | @interface GPBExtensionDescriptor : NSObject<NSCopying> |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 297 | /** Field number under which the extension is stored. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 298 | @property(nonatomic, readonly) uint32_t fieldNumber; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 299 | /** The containing message class, i.e. the class extended by this extension. */ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 300 | @property(nonatomic, readonly) Class containingMessageClass; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 301 | /** Data type contained in the extension. */ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 302 | @property(nonatomic, readonly) GPBDataType dataType; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 303 | /** Whether the extension is repeated. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 304 | @property(nonatomic, readonly, getter=isRepeated) BOOL repeated; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 305 | /** Whether the extension is packable. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 306 | @property(nonatomic, readonly, getter=isPackable) BOOL packable; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 307 | /** The class of the message if the extension is of message type. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 308 | @property(nonatomic, readonly, assign) Class msgClass; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 309 | /** The singleton name for the extension. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 310 | @property(nonatomic, readonly) NSString *singletonName; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 311 | /** The enum descriptor if the extension is of enum type. */ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 312 | @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 313 | /** The default value for the extension. */ |
Thomas Van Lenten | c8a440d | 2016-05-25 13:46:00 -0400 | [diff] [blame] | 314 | @property(nonatomic, readonly, nullable) id defaultValue; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 315 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 316 | @end |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 317 | |
| 318 | NS_ASSUME_NONNULL_END |