Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/protobuf/objectivec/GPBDescriptor.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
32 32
33 #import "GPBRuntimeTypes.h" 33 #import "GPBRuntimeTypes.h"
34 34
35 @class GPBEnumDescriptor; 35 @class GPBEnumDescriptor;
36 @class GPBFieldDescriptor; 36 @class GPBFieldDescriptor;
37 @class GPBFileDescriptor; 37 @class GPBFileDescriptor;
38 @class GPBOneofDescriptor; 38 @class GPBOneofDescriptor;
39 39
40 NS_ASSUME_NONNULL_BEGIN 40 NS_ASSUME_NONNULL_BEGIN
41 41
42 /** Syntax used in the proto file. */
42 typedef NS_ENUM(uint8_t, GPBFileSyntax) { 43 typedef NS_ENUM(uint8_t, GPBFileSyntax) {
44 /** Unknown syntax. */
43 GPBFileSyntaxUnknown = 0, 45 GPBFileSyntaxUnknown = 0,
46 /** Proto2 syntax. */
44 GPBFileSyntaxProto2 = 2, 47 GPBFileSyntaxProto2 = 2,
48 /** Proto3 syntax. */
45 GPBFileSyntaxProto3 = 3, 49 GPBFileSyntaxProto3 = 3,
46 }; 50 };
47 51
52 /** Type of proto field. */
48 typedef NS_ENUM(uint8_t, GPBFieldType) { 53 typedef NS_ENUM(uint8_t, GPBFieldType) {
49 GPBFieldTypeSingle, // optional/required 54 /** Optional/required field. Only valid for proto2 fields. */
50 GPBFieldTypeRepeated, // repeated 55 GPBFieldTypeSingle,
51 GPBFieldTypeMap, // map<K,V> 56 /** Repeated field. */
57 GPBFieldTypeRepeated,
58 /** Map field. */
59 GPBFieldTypeMap,
52 }; 60 };
53 61
62 /**
63 * Describes a proto message.
64 **/
54 @interface GPBDescriptor : NSObject<NSCopying> 65 @interface GPBDescriptor : NSObject<NSCopying>
55 66
67 /** Name of the message. */
56 @property(nonatomic, readonly, copy) NSString *name; 68 @property(nonatomic, readonly, copy) NSString *name;
69 /** Fields declared in the message. */
57 @property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *f ields; 70 @property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *f ields;
71 /** Oneofs declared in the message. */
58 @property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *o neofs; 72 @property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *o neofs;
73 /** Extension range declared for the message. */
59 @property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRange s; 74 @property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRange s;
75 /** Number of extension ranges declared for the message. */
60 @property(nonatomic, readonly) uint32_t extensionRangesCount; 76 @property(nonatomic, readonly) uint32_t extensionRangesCount;
77 /** Descriptor for the file where the message was defined. */
61 @property(nonatomic, readonly, assign) GPBFileDescriptor *file; 78 @property(nonatomic, readonly, assign) GPBFileDescriptor *file;
62 79
80 /** Whether the message is in wire format or not. */
63 @property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat; 81 @property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
82 /** The class of this message. */
64 @property(nonatomic, readonly) Class messageClass; 83 @property(nonatomic, readonly) Class messageClass;
65 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;
91
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 **/
66 - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; 99 - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
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 **/
67 - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; 108 - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
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 **/
68 - (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name; 117 - (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
69 118
70 @end 119 @end
71 120
121 /**
122 * Describes a proto file.
123 **/
72 @interface GPBFileDescriptor : NSObject 124 @interface GPBFileDescriptor : NSObject
73 125
126 /** The package declared in the proto file. */
74 @property(nonatomic, readonly, copy) NSString *package; 127 @property(nonatomic, readonly, copy) NSString *package;
128 /** The objc prefix declared in the proto file. */
129 @property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
130 /** The syntax of the proto file. */
75 @property(nonatomic, readonly) GPBFileSyntax syntax; 131 @property(nonatomic, readonly) GPBFileSyntax syntax;
76 132
77 @end 133 @end
78 134
135 /**
136 * Describes a oneof field.
137 **/
79 @interface GPBOneofDescriptor : NSObject 138 @interface GPBOneofDescriptor : NSObject
139 /** Name of the oneof field. */
80 @property(nonatomic, readonly) NSString *name; 140 @property(nonatomic, readonly) NSString *name;
141 /** Fields declared in the oneof. */
81 @property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields; 142 @property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
82 143
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 **/
83 - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber; 151 - (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
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 **/
84 - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name; 160 - (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
85 @end 161
86 162 @end
163
164 /**
165 * Describes a proto field.
166 **/
87 @interface GPBFieldDescriptor : NSObject 167 @interface GPBFieldDescriptor : NSObject
88 168
169 /** Name of the field. */
89 @property(nonatomic, readonly, copy) NSString *name; 170 @property(nonatomic, readonly, copy) NSString *name;
171 /** Number associated with the field. */
90 @property(nonatomic, readonly) uint32_t number; 172 @property(nonatomic, readonly) uint32_t number;
173 /** Data type contained in the field. */
91 @property(nonatomic, readonly) GPBDataType dataType; 174 @property(nonatomic, readonly) GPBDataType dataType;
175 /** Whether it has a default value or not. */
92 @property(nonatomic, readonly) BOOL hasDefaultValue; 176 @property(nonatomic, readonly) BOOL hasDefaultValue;
177 /** Default value for the field. */
93 @property(nonatomic, readonly) GPBGenericValue defaultValue; 178 @property(nonatomic, readonly) GPBGenericValue defaultValue;
179 /** Whether this field is required. Only valid for proto2 fields. */
94 @property(nonatomic, readonly, getter=isRequired) BOOL required; 180 @property(nonatomic, readonly, getter=isRequired) BOOL required;
181 /** Whether this field is optional. */
95 @property(nonatomic, readonly, getter=isOptional) BOOL optional; 182 @property(nonatomic, readonly, getter=isOptional) BOOL optional;
183 /** Type of field (single, repeated, map). */
96 @property(nonatomic, readonly) GPBFieldType fieldType; 184 @property(nonatomic, readonly) GPBFieldType fieldType;
97 // If it is a map, the value type is in -type. 185 /** Type of the key if the field is a map. The value's type is -fieldType. */
98 @property(nonatomic, readonly) GPBDataType mapKeyDataType; 186 @property(nonatomic, readonly) GPBDataType mapKeyDataType;
187 /** Whether the field is packable. */
99 @property(nonatomic, readonly, getter=isPackable) BOOL packable; 188 @property(nonatomic, readonly, getter=isPackable) BOOL packable;
100 189
190 /** The containing oneof if this field is part of one, nil otherwise. */
101 @property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingO neof; 191 @property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingO neof;
102 192
103 // Message properties 193 /** Class of the message if the field is of message type. */
104 @property(nonatomic, readonly, assign, nullable) Class msgClass; 194 @property(nonatomic, readonly, assign, nullable) Class msgClass;
105 195
106 // Enum properties 196 /** Descriptor for the enum if this field is an enum. */
107 @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescript or; 197 @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescript or;
108 198
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 **/
109 - (BOOL)isValidEnumValue:(int32_t)value; 206 - (BOOL)isValidEnumValue:(int32_t)value;
110 207
111 // For now, this will return nil if it doesn't know the name to use for 208 /** @return Name for the text format, or nil if not known. */
112 // TextFormat.
113 - (nullable NSString *)textFormatName; 209 - (nullable NSString *)textFormatName;
114 210
115 @end 211 @end
116 212
213 /**
214 * Describes a proto enum.
215 **/
117 @interface GPBEnumDescriptor : NSObject 216 @interface GPBEnumDescriptor : NSObject
118 217
218 /** Name of the enum. */
119 @property(nonatomic, readonly, copy) NSString *name; 219 @property(nonatomic, readonly, copy) NSString *name;
220 /** Function that validates that raw values are valid enum values. */
120 @property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier; 221 @property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
121 222
223 /**
224 * Returns the enum value name for the given raw enum.
225 *
226 * @param number The raw enum value.
227 *
228 * @return The name of the enum value passed, or nil if not valid.
229 **/
122 - (nullable NSString *)enumNameForValue:(int32_t)number; 230 - (nullable NSString *)enumNameForValue:(int32_t)number;
231
232 /**
233 * Gets the enum raw value for the given enum name.
234 *
235 * @param outValue A pointer where the value will be set.
236 * @param name The enum name for which to get the raw value.
237 *
238 * @return YES if a value was copied into the pointer, NO otherwise.
239 **/
123 - (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name; 240 - (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
124 241
242 /**
243 * Returns the text format for the given raw enum value.
244 *
245 * @param number The raw enum value.
246 *
247 * @return The text format name for the raw enum value, or nil if not valid.
248 **/
125 - (nullable NSString *)textFormatNameForValue:(int32_t)number; 249 - (nullable NSString *)textFormatNameForValue:(int32_t)number;
126 250
127 @end 251 /**
128 252 * Gets the enum raw value for the given text format name.
253 *
254 * @param outValue A pointer where the value will be set.
255 * @param textFormatName The text format name for which to get the raw value.
256 *
257 * @return YES if a value was copied into the pointer, NO otherwise.
258 **/
259 - (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *) textFormatName;
260
261 @end
262
263 /**
264 * Describes a proto extension.
265 **/
129 @interface GPBExtensionDescriptor : NSObject<NSCopying> 266 @interface GPBExtensionDescriptor : NSObject<NSCopying>
267 /** Field number under which the extension is stored. */
130 @property(nonatomic, readonly) uint32_t fieldNumber; 268 @property(nonatomic, readonly) uint32_t fieldNumber;
269 /** The containing message class, i.e. the class extended by this extension. */
131 @property(nonatomic, readonly) Class containingMessageClass; 270 @property(nonatomic, readonly) Class containingMessageClass;
271 /** Data type contained in the extension. */
132 @property(nonatomic, readonly) GPBDataType dataType; 272 @property(nonatomic, readonly) GPBDataType dataType;
273 /** Whether the extension is repeated. */
133 @property(nonatomic, readonly, getter=isRepeated) BOOL repeated; 274 @property(nonatomic, readonly, getter=isRepeated) BOOL repeated;
275 /** Whether the extension is packable. */
134 @property(nonatomic, readonly, getter=isPackable) BOOL packable; 276 @property(nonatomic, readonly, getter=isPackable) BOOL packable;
277 /** The class of the message if the extension is of message type. */
135 @property(nonatomic, readonly, assign) Class msgClass; 278 @property(nonatomic, readonly, assign) Class msgClass;
279 /** The singleton name for the extension. */
136 @property(nonatomic, readonly) NSString *singletonName; 280 @property(nonatomic, readonly) NSString *singletonName;
281 /** The enum descriptor if the extension is of enum type. */
137 @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescript or; 282 @property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescript or;
138 @property(nonatomic, readonly) id defaultValue; 283 /** The default value for the extension. */
284 @property(nonatomic, readonly, nullable) id defaultValue;
285
139 @end 286 @end
140 287
141 NS_ASSUME_NONNULL_END 288 NS_ASSUME_NONNULL_END
OLDNEW
« no previous file with comments | « third_party/protobuf/objectivec/GPBCodedOutputStream.m ('k') | third_party/protobuf/objectivec/GPBDescriptor.m » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698