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

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

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 3 years, 12 months 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 26 matching lines...) Expand all
37 @class GPBCodedOutputStream; 37 @class GPBCodedOutputStream;
38 @class GPBExtensionDescriptor; 38 @class GPBExtensionDescriptor;
39 @class GPBExtensionRegistry; 39 @class GPBExtensionRegistry;
40 @class GPBFieldDescriptor; 40 @class GPBFieldDescriptor;
41 @class GPBUnknownFieldSet; 41 @class GPBUnknownFieldSet;
42 42
43 NS_ASSUME_NONNULL_BEGIN 43 NS_ASSUME_NONNULL_BEGIN
44 44
45 CF_EXTERN_C_BEGIN 45 CF_EXTERN_C_BEGIN
46 46
47 /// NSError domain used for errors. 47 /** NSError domain used for errors. */
48 extern NSString *const GPBMessageErrorDomain; 48 extern NSString *const GPBMessageErrorDomain;
49 49
50 /// Error code for NSError with GPBMessageErrorDomain. 50 /** Error codes for NSErrors originated in GPBMessage. */
51 typedef NS_ENUM(NSInteger, GPBMessageErrorCode) { 51 typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
52 /// The data being parsed is bad and a message can not be created from it. 52 /** Uncategorized error. */
53 GPBMessageErrorCodeMalformedData = -100, 53 GPBMessageErrorCodeOther = -100,
54 /// A message can't be serialized because it is missing required fields. 54 /** Message couldn't be serialized because it is missing required fields. */
55 GPBMessageErrorCodeMissingRequiredField = -101, 55 GPBMessageErrorCodeMissingRequiredField = -101,
56 }; 56 };
57 57
58 #ifdef DEBUG 58 /**
59 /// In DEBUG ONLY, an NSException is thrown when a parsed message doesn't 59 * Key under which the GPBMessage error's reason is stored inside the userInfo
60 /// contain required fields. This key allows you to retrieve the parsed message 60 * dictionary.
61 /// from the exception's @c userInfo dictionary. 61 **/
62 extern NSString *const GPBExceptionMessageKey; 62 extern NSString *const GPBErrorReasonKey;
63 #endif // DEBUG
64 63
65 CF_EXTERN_C_END 64 CF_EXTERN_C_END
66 65
67 /// Base class for all of the generated message classes. 66 /**
67 * Base class that each generated message subclasses from.
68 *
69 * @note While the class support NSSecureCoding, if the message has any
70 * extensions, they will end up reloaded in @c unknownFields as there is
71 * no way for the @c NSCoding plumbing to pass through a
72 * @c GPBExtensionRegistry. To support extensions, instead of passing the
73 * calls off to the Message, simple store the result of @c data, and then
74 * when loading, fetch the data and use
75 * @c +parseFromData:extensionRegistry:error: to provide an extension
76 * registry.
77 **/
68 @interface GPBMessage : NSObject<NSSecureCoding, NSCopying> 78 @interface GPBMessage : NSObject<NSSecureCoding, NSCopying>
69 79
70 // NOTE: If you add a instance method/property to this class that may conflict 80 // If you add an instance method/property to this class that may conflict with
71 // with methods declared in protos, you need to update objective_helpers.cc. 81 // fields declared in protos, you need to update objective_helpers.cc. The main
72 // The main cases are methods that take no arguments, or setFoo:/hasFoo: type 82 // cases are methods that take no arguments, or setFoo:/hasFoo: type methods.
73 // methods. 83
74 84 /**
75 /// The unknown fields for this message. 85 * The set of unknown fields for this message.
76 /// 86 *
77 /// Only messages from proto files declared with "proto2" syntax support unknown 87 * Only messages from proto files declared with "proto2" syntax support unknown
78 /// fields. For "proto3" syntax, any unknown fields found while parsing are 88 * fields. For "proto3" syntax, any unknown fields found while parsing are
79 /// dropped. 89 * dropped.
90 **/
80 @property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields; 91 @property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
81 92
82 /// Are all required fields set in the message and all embedded messages. 93 /**
94 * Whether the message, along with all submessages, have the required fields
95 * set. This is only applicable for files declared with "proto2" syntax, as
96 * there are no required fields for "proto3" syntax.
97 **/
83 @property(nonatomic, readonly, getter=isInitialized) BOOL initialized; 98 @property(nonatomic, readonly, getter=isInitialized) BOOL initialized;
84 99
85 /// Returns an autoreleased instance. 100 /**
101 * @return An autoreleased message with the default values set.
102 **/
86 + (instancetype)message; 103 + (instancetype)message;
87 104
88 /// Creates a new instance by parsing the data. This method should be sent to 105 /**
89 /// the generated message class that the data should be interpreted as. If 106 * Creates a new instance by parsing the provided data. This method should be
90 /// there is an error the method returns nil and the error is returned in 107 * sent to the generated message class that the data should be interpreted as.
91 /// errorPtr (when provided). 108 * If there is an error the method returns nil and the error is returned in
92 /// 109 * errorPtr (when provided).
93 /// @note In DEBUG builds, the parsed message is checked to be sure all required 110 *
94 /// fields were provided, and the parse will fail if some are missing. 111 * @note In DEBUG builds, the parsed message is checked to be sure all required
95 /// 112 * fields were provided, and the parse will fail if some are missing.
96 /// @param data The data to parse. 113 *
97 /// @param errorPtr An optional error pointer to fill in with a failure reason i f 114 * @note The errors returned are likely coming from the domain and codes listed
98 /// the data can not be parsed. 115 * at the top of this file and GPBCodedInputStream.h.
99 /// 116 *
100 /// @return A new instance of the class messaged. 117 * @param data The data to parse.
101 + (instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr; 118 * @param errorPtr An optional error pointer to fill in with a failure reason if
102 119 * the data can not be parsed.
103 /// Creates a new instance by parsing the data. This method should be sent to 120 *
104 /// the generated message class that the data should be interpreted as. If 121 * @return A new instance of the generated class.
105 /// there is an error the method returns nil and the error is returned in 122 **/
106 /// errorPtr (when provided). 123 + (nullable instancetype)parseFromData:(NSData *)data error:(NSError **)errorPtr ;
107 /// 124
108 /// @note In DEBUG builds, the parsed message is checked to be sure all required 125 /**
109 /// fields were provided, and the parse will fail if some are missing. 126 * Creates a new instance by parsing the data. This method should be sent to
110 /// 127 * the generated message class that the data should be interpreted as. If
111 /// @param data The data to parse. 128 * there is an error the method returns nil and the error is returned in
112 /// @param extensionRegistry The extension registry to use to look up extensions . 129 * errorPtr (when provided).
113 /// @param errorPtr An optional error pointer to fill in with a failure 130 *
114 /// reason if the data can not be parsed. 131 * @note In DEBUG builds, the parsed message is checked to be sure all required
115 /// 132 * fields were provided, and the parse will fail if some are missing.
116 /// @return A new instance of the class messaged. 133 *
117 + (instancetype)parseFromData:(NSData *)data 134 * @note The errors returned are likely coming from the domain and codes listed
118 extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry 135 * at the top of this file and GPBCodedInputStream.h.
119 error:(NSError **)errorPtr; 136 *
120 137 * @param data The data to parse.
121 /// Creates a new instance by parsing the data from the given input stream. This 138 * @param extensionRegistry The extension registry to use to look up extensions.
122 /// method should be sent to the generated message class that the data should 139 * @param errorPtr An optional error pointer to fill in with a failure
123 /// be interpreted as. If there is an error the method returns nil and the error 140 * reason if the data can not be parsed.
124 /// is returned in errorPtr (when provided). 141 *
125 /// 142 * @return A new instance of the generated class.
126 /// @note In DEBUG builds, the parsed message is checked to be sure all required 143 **/
127 /// fields were provided, and the parse will fail if some are missing. 144 + (nullable instancetype)parseFromData:(NSData *)data
128 /// 145 extensionRegistry:(nullable GPBExtensionRegistry *)extensio nRegistry
129 /// @param input The stream to read data from. 146 error:(NSError **)errorPtr;
130 /// @param extensionRegistry The extension registry to use to look up extensions . 147
131 /// @param errorPtr An optional error pointer to fill in with a failure 148 /**
132 /// reason if the data can not be parsed. 149 * Creates a new instance by parsing the data from the given input stream. This
133 /// 150 * method should be sent to the generated message class that the data should
134 /// @return A new instance of the class messaged. 151 * be interpreted as. If there is an error the method returns nil and the error
135 + (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input 152 * is returned in errorPtr (when provided).
136 extensionRegistry: 153 *
137 (nullable GPBExtensionRegistry *)extensionRegistry 154 * @note In DEBUG builds, the parsed message is checked to be sure all required
138 error:(NSError **)errorPtr; 155 * fields were provided, and the parse will fail if some are missing.
139 156 *
140 /// Creates a new instance by parsing the data from the given input stream. This 157 * @note The errors returned are likely coming from the domain and codes listed
141 /// method should be sent to the generated message class that the data should 158 * at the top of this file and GPBCodedInputStream.h.
142 /// be interpreted as. If there is an error the method returns nil and the error 159 *
143 /// is returned in errorPtr (when provided). 160 * @param input The stream to read data from.
144 /// 161 * @param extensionRegistry The extension registry to use to look up extensions.
145 /// @note Unlike the parseFrom... methods, this never checks to see if all of 162 * @param errorPtr An optional error pointer to fill in with a failure
146 /// the required fields are set. So this method can be used to reload 163 * reason if the data can not be parsed.
147 /// messages that may not be complete. 164 *
148 /// 165 * @return A new instance of the generated class.
149 /// @param input The stream to read data from. 166 **/
150 /// @param extensionRegistry The extension registry to use to look up extensions . 167 + (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
151 /// @param errorPtr An optional error pointer to fill in with a failure
152 /// reason if the data can not be parsed.
153 ///
154 /// @return A new instance of the class messaged.
155 + (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
156 extensionRegistry: 168 extensionRegistry:
157 (nullable GPBExtensionRegistry *)extensionR egistry 169 (nullable GPBExtensionRegistry *)extensionR egistry
158 error:(NSError **)errorPtr; 170 error:(NSError **)errorPtr;
159 171
160 /// Initializes an instance by parsing the data. This method should be sent to 172 /**
161 /// the generated message class that the data should be interpreted as. If 173 * Creates a new instance by parsing the data from the given input stream. This
162 /// there is an error the method returns nil and the error is returned in 174 * method should be sent to the generated message class that the data should
163 /// errorPtr (when provided). 175 * be interpreted as. If there is an error the method returns nil and the error
164 /// 176 * is returned in errorPtr (when provided).
165 /// @note In DEBUG builds, the parsed message is checked to be sure all required 177 *
166 /// fields were provided, and the parse will fail if some are missing. 178 * @note Unlike the parseFrom... methods, this never checks to see if all of
167 /// 179 * the required fields are set. So this method can be used to reload
168 /// @param data The data to parse. 180 * messages that may not be complete.
169 /// @param errorPtr An optional error pointer to fill in with a failure reason i f 181 *
170 /// the data can not be parsed. 182 * @note The errors returned are likely coming from the domain and codes listed
171 - (instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr; 183 * at the top of this file and GPBCodedInputStream.h.
172 184 *
173 /// Initializes an instance by parsing the data. This method should be sent to 185 * @param input The stream to read data from.
174 /// the generated message class that the data should be interpreted as. If 186 * @param extensionRegistry The extension registry to use to look up extensions.
175 /// there is an error the method returns nil and the error is returned in 187 * @param errorPtr An optional error pointer to fill in with a failure
176 /// errorPtr (when provided). 188 * reason if the data can not be parsed.
177 /// 189 *
178 /// @note In DEBUG builds, the parsed message is checked to be sure all required 190 * @return A new instance of the generated class.
179 /// fields were provided, and the parse will fail if some are missing. 191 **/
180 /// 192 + (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
181 /// @param data The data to parse. 193 extensionRegistry:
182 /// @param extensionRegistry The extension registry to use to look up extensions . 194 (nullable GPBExtensionRegistry *)e xtensionRegistry
183 /// @param errorPtr An optional error pointer to fill in with a failure 195 error:(NSError **)errorPtr ;
184 /// reason if the data can not be parsed. 196
185 - (instancetype)initWithData:(NSData *)data 197 /**
186 extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry 198 * Initializes an instance by parsing the data. This method should be sent to
187 error:(NSError **)errorPtr; 199 * the generated message class that the data should be interpreted as. If
188 200 * there is an error the method returns nil and the error is returned in
189 /// Initializes an instance by parsing the data from the given input stream. Thi s 201 * errorPtr (when provided).
190 /// method should be sent to the generated message class that the data should 202 *
191 /// be interpreted as. If there is an error the method returns nil and the error 203 * @note In DEBUG builds, the parsed message is checked to be sure all required
192 /// is returned in errorPtr (when provided). 204 * fields were provided, and the parse will fail if some are missing.
193 /// 205 *
194 /// @note Unlike the parseFrom... methods, this never checks to see if all of 206 * @note The errors returned are likely coming from the domain and codes listed
195 /// the required fields are set. So this method can be used to reload 207 * at the top of this file and GPBCodedInputStream.h.
196 /// messages that may not be complete. 208 *
197 /// 209 * @param data The data to parse.
198 /// @param input The stream to read data from. 210 * @param errorPtr An optional error pointer to fill in with a failure reason if
199 /// @param extensionRegistry The extension registry to use to look up extensions . 211 * the data can not be parsed.
200 /// @param errorPtr An optional error pointer to fill in with a failure 212 *
201 /// reason if the data can not be parsed. 213 * @return An initialized instance of the generated class.
202 - (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input 214 **/
203 extensionRegistry: 215 - (nullable instancetype)initWithData:(NSData *)data error:(NSError **)errorPtr;
204 (nullable GPBExtensionRegistry *)extensionRegistry 216
205 error:(NSError **)errorPtr; 217 /**
206 218 * Initializes an instance by parsing the data. This method should be sent to
207 /// Writes out the message to the given output stream. 219 * the generated message class that the data should be interpreted as. If
220 * there is an error the method returns nil and the error is returned in
221 * errorPtr (when provided).
222 *
223 * @note In DEBUG builds, the parsed message is checked to be sure all required
224 * fields were provided, and the parse will fail if some are missing.
225 *
226 * @note The errors returned are likely coming from the domain and codes listed
227 * at the top of this file and GPBCodedInputStream.h.
228 *
229 * @param data The data to parse.
230 * @param extensionRegistry The extension registry to use to look up extensions.
231 * @param errorPtr An optional error pointer to fill in with a failure
232 * reason if the data can not be parsed.
233 *
234 * @return An initialized instance of the generated class.
235 **/
236 - (nullable instancetype)initWithData:(NSData *)data
237 extensionRegistry:(nullable GPBExtensionRegistry *)extension Registry
238 error:(NSError **)errorPtr;
239
240 /**
241 * Initializes an instance by parsing the data from the given input stream. This
242 * method should be sent to the generated message class that the data should
243 * be interpreted as. If there is an error the method returns nil and the error
244 * is returned in errorPtr (when provided).
245 *
246 * @note Unlike the parseFrom... methods, this never checks to see if all of
247 * the required fields are set. So this method can be used to reload
248 * messages that may not be complete.
249 *
250 * @note The errors returned are likely coming from the domain and codes listed
251 * at the top of this file and GPBCodedInputStream.h.
252 *
253 * @param input The stream to read data from.
254 * @param extensionRegistry The extension registry to use to look up extensions.
255 * @param errorPtr An optional error pointer to fill in with a failure
256 * reason if the data can not be parsed.
257 *
258 * @return An initialized instance of the generated class.
259 **/
260 - (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
261 extensionRegistry:
262 (nullable GPBExtensionRegistry *)extensionRe gistry
263 error:(NSError **)errorPtr;
264
265 /**
266 * Parses the given data as this message's class, and merges those values into
267 * this message.
268 *
269 * @param data The binary representation of the message to merge.
270 * @param extensionRegistry The extension registry to use to look up extensions.
271 *
272 * @exception GPBCodedInputStreamException Exception thrown when parsing was
273 * unsuccessful.
274 **/
275 - (void)mergeFromData:(NSData *)data
276 extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
277
278 /**
279 * Merges the fields from another message (of the same type) into this
280 * message.
281 *
282 * @param other Message to merge into this message.
283 **/
284 - (void)mergeFrom:(GPBMessage *)other;
285
286 /**
287 * Writes out the message to the given coded output stream.
288 *
289 * @param output The coded output stream into which to write the message.
290 **/
208 - (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output; 291 - (void)writeToCodedOutputStream:(GPBCodedOutputStream *)output;
209 /// Writes out the message to the given output stream. 292
293 /**
294 * Writes out the message to the given output stream.
295 *
296 * @param output The output stream into which to write the message.
297 **/
210 - (void)writeToOutputStream:(NSOutputStream *)output; 298 - (void)writeToOutputStream:(NSOutputStream *)output;
211 299
212 /// Writes out a varint for the message size followed by the the message to 300 /**
213 /// the given output stream. 301 * Writes out a varint for the message size followed by the the message to
302 * the given output stream.
303 *
304 * @param output The coded output stream into which to write the message.
305 **/
214 - (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output; 306 - (void)writeDelimitedToCodedOutputStream:(GPBCodedOutputStream *)output;
215 /// Writes out a varint for the message size followed by the the message to 307
216 /// the given output stream. 308 /**
309 * Writes out a varint for the message size followed by the the message to
310 * the given output stream.
311 *
312 * @param output The output stream into which to write the message.
313 **/
217 - (void)writeDelimitedToOutputStream:(NSOutputStream *)output; 314 - (void)writeDelimitedToOutputStream:(NSOutputStream *)output;
218 315
219 /// Serializes the message to a @c NSData. 316 /**
220 /// 317 * Serializes the message to an NSData.
221 /// If there is an error while generating the data, nil is returned. 318 *
222 /// 319 * If there is an error while generating the data, nil is returned.
223 /// @note This value is not cached, so if you are using it repeatedly, cache 320 *
224 /// it yourself. 321 * @note This value is not cached, so if you are using it repeatedly, cache
225 /// 322 * it yourself.
226 /// @note In DEBUG ONLY, the message is also checked for all required field, 323 *
227 /// if one is missing, nil will be returned. 324 * @note In DEBUG ONLY, the message is also checked for all required field,
325 * if one is missing, nil will be returned.
326 *
327 * @return The binary representation of the message.
328 **/
228 - (nullable NSData *)data; 329 - (nullable NSData *)data;
229 330
230 /// Serializes a varint with the message size followed by the message data, 331 /**
231 /// returning that as a @c NSData. 332 * Serializes a varint with the message size followed by the message data,
232 /// 333 * returning that as an NSData.
233 /// @note This value is not cached, so if you are using it repeatedly, cache 334 *
234 /// it yourself. 335 * @note This value is not cached, so if you are using it repeatedly, it is
336 * recommended to keep a local copy.
337 *
338 * @return The binary representation of the size along with the message.
339 **/
235 - (NSData *)delimitedData; 340 - (NSData *)delimitedData;
236 341
237 /// Calculates the size of the object if it were serialized. 342 /**
238 /// 343 * Calculates the size of the object if it were serialized.
239 /// This is not a cached value. If you are following a pattern like this: 344 *
240 /// @code 345 * This is not a cached value. If you are following a pattern like this:
241 /// size_t size = [aMsg serializedSize]; 346 *
242 /// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; 347 * ```
243 /// [foo writeSize:size]; 348 * size_t size = [aMsg serializedSize];
244 /// [foo appendData:[aMsg data]]; 349 * NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
245 /// @endcode 350 * [foo writeSize:size];
246 /// you would be better doing: 351 * [foo appendData:[aMsg data]];
247 /// @code 352 * ```
248 /// NSData *data = [aMsg data]; 353 *
249 /// NSUInteger size = [aMsg length]; 354 * you would be better doing:
250 /// NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)]; 355 *
251 /// [foo writeSize:size]; 356 * ```
252 /// [foo appendData:data]; 357 * NSData *data = [aMsg data];
253 /// @endcode 358 * NSUInteger size = [aMsg length];
359 * NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
360 * [foo writeSize:size];
361 * [foo appendData:data];
362 * ```
363 *
364 * @return The size of the message in it's binary representation.
365 **/
254 - (size_t)serializedSize; 366 - (size_t)serializedSize;
255 367
256 /// Return the descriptor for the message class. 368 /**
369 * @return The descriptor for the message class.
370 **/
257 + (GPBDescriptor *)descriptor; 371 + (GPBDescriptor *)descriptor;
258 /// Return the descriptor for the message. 372
373 /**
374 * Return the descriptor for the message.
375 **/
259 - (GPBDescriptor *)descriptor; 376 - (GPBDescriptor *)descriptor;
260 377
261 /// Test to see if the given extension is set on the message. 378 /**
379 * @return An array with the extension descriptors that are currently set on the
380 * message.
381 **/
382 - (NSArray *)extensionsCurrentlySet;
383
384 /**
385 * Checks whether there is an extension set on the message which matches the
386 * given extension descriptor.
387 *
388 * @param extension Extension descriptor to check if it's set on the message.
389 *
390 * @return Whether the extension is currently set on the message.
391 **/
262 - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension; 392 - (BOOL)hasExtension:(GPBExtensionDescriptor *)extension;
263 393
264 /// Fetches the given extension's value for this message. 394 /*
265 /// 395 * Fetches the given extension's value for this message.
266 /// Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for 396 *
267 /// repeated fields. If the extension is a Message one will be auto created for you 397 * Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for
268 /// and returned similar to fields. 398 * repeated fields. If the extension is a Message one will be auto created for
399 * you and returned similar to fields.
400 *
401 * @param extension The extension descriptor of the extension to fetch.
402 *
403 * @return The extension matching the given descriptor, or nil if none found.
404 **/
269 - (nullable id)getExtension:(GPBExtensionDescriptor *)extension; 405 - (nullable id)getExtension:(GPBExtensionDescriptor *)extension;
270 406
271 /// Sets the given extension's value for this message. This is only for single 407 /**
272 /// field extensions (i.e. - not repeated fields). 408 * Sets the given extension's value for this message. This only applies for
273 /// 409 * single field extensions (i.e. - not repeated fields).
274 /// Extensions use boxed values (@c NSNumbers). 410 *
275 - (void)setExtension:(GPBExtensionDescriptor *)extension value:(nullable id)valu e; 411 * Extensions use boxed values (NSNumbers).
276 412 *
277 /// Adds the given value to the extension for this message. This is only for 413 * @param extension The extension descriptor under which to set the value.
278 /// repeated field extensions. If the field is a repeated POD type the @c value 414 * @param value The value to be set as the extension.
279 /// is a @c NSNumber. 415 **/
416 - (void)setExtension:(GPBExtensionDescriptor *)extension
417 value:(nullable id)value;
418
419 /**
420 * Adds the given value to the extension for this message. This only applies
421 * to repeated field extensions. If the field is a repeated POD type, the value
422 * should be an NSNumber.
423 *
424 * @param extension The extension descriptor under which to add the value.
425 * @param value The value to be added to the repeated extension.
426 **/
280 - (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value; 427 - (void)addExtension:(GPBExtensionDescriptor *)extension value:(id)value;
281 428
282 /// Replaces the given value at an index for the extension on this message. This 429 /**
283 /// is only for repeated field extensions. If the field is a repeated POD type 430 * Replaces the value at the given index with the given value for the extension
284 /// the @c value is a @c NSNumber. 431 * on this message. This only applies to repeated field extensions. If the field
432 * is a repeated POD type, the value is should be an NSNumber.
433 *
434 * @param extension The extension descriptor under which to replace the value.
435 * @param index The index of the extension to be replaced.
436 * @param value The value to be replaced in the repeated extension.
437 **/
285 - (void)setExtension:(GPBExtensionDescriptor *)extension 438 - (void)setExtension:(GPBExtensionDescriptor *)extension
286 index:(NSUInteger)index 439 index:(NSUInteger)index
287 value:(id)value; 440 value:(id)value;
288 441
289 /// Clears the given extension for this message. 442 /**
443 * Clears the given extension for this message.
444 *
445 * @param extension The extension descriptor to be cleared from this message.
446 **/
290 - (void)clearExtension:(GPBExtensionDescriptor *)extension; 447 - (void)clearExtension:(GPBExtensionDescriptor *)extension;
291 448
292 /// Resets all of the fields of this message to their default values. 449 /**
450 * Resets all of the fields of this message to their default values.
451 **/
293 - (void)clear; 452 - (void)clear;
294 453
295 /// Parses a message of this type from the input and merges it with this
296 /// message.
297 ///
298 /// @note This will throw if there is an error parsing the data.
299 - (void)mergeFromData:(NSData *)data
300 extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
301
302 /// Merges the fields from another message (of the same type) into this
303 /// message.
304 - (void)mergeFrom:(GPBMessage *)other;
305
306 @end 454 @end
307 455
308 NS_ASSUME_NONNULL_END 456 NS_ASSUME_NONNULL_END
OLDNEW
« no previous file with comments | « third_party/protobuf/objectivec/GPBExtensionRegistry.m ('k') | third_party/protobuf/objectivec/GPBMessage.m » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698