#import <GPBMessage.h>
Instance Methods | |
(void) | - addExtension:value: |
(void) | - addUnknownMapEntry:value: [implementation] |
(void) | - clear |
(void) | - clearExtension: |
(nullable NSData *) | - data |
(NSData *) | - delimitedData |
(GPBDescriptor *) | - descriptor |
(NSArray *) | - extensionsCurrentlySet |
(id) | - getExistingExtension: [implementation] |
(nullable id) | - getExtension: |
(BOOL) | - hasExtension: |
(nullable instancetype) | - initWithCodedInputStream:extensionRegistry:error: |
(nullable instancetype) | - initWithData:error: |
(nullable instancetype) | - initWithData:extensionRegistry:error: |
(void) | - mergeDelimitedFromCodedInputStream:extensionRegistry: [implementation] |
(void) | - mergeFrom: |
(void) | - mergeFromCodedInputStream:extensionRegistry: [implementation] |
(void) | - mergeFromData:extensionRegistry: |
(size_t) | - serializedSize |
(void) | - setExtension:index:value: |
(void) | - setExtension:value: |
(void) | - writeDelimitedToCodedOutputStream: |
(void) | - writeDelimitedToOutputStream: |
(void) | - writeToCodedOutputStream: |
(void) | - writeToOutputStream: |
Class Methods | |
(GPBDescriptor *) | + descriptor |
(instancetype) | + message |
(nullable instancetype) | + parseDelimitedFromCodedInputStream:extensionRegistry:error: |
(nullable instancetype) | + parseFromCodedInputStream:extensionRegistry:error: |
(nullable instancetype) | + parseFromData:error: |
(nullable instancetype) | + parseFromData:extensionRegistry:error: |
Protected Attributes | |
package GPBMessage_StoragePtr | messageStorage_ |
Properties | |
BOOL | initialized |
GPBUnknownFieldSet * | unknownFields |
Base class that each generated message subclasses from.
NSCopying
support is a "deep copy", in that all sub objects are copied. Just like you wouldn't want a UIView/NSView trying to exist in two places, you don't want a sub message to be a property property of two other messages.unknownFields
as there is no way for the NSCoding
plumbing to pass through a GPBExtensionRegistry
. To support extensions, instead of passing the calls off to the Message, simple store the result of data
, and then when loading, fetch the data and use +parseFromData:extensionRegistry:error:
to provide an extension registry. Definition at line 83 of file GPBMessage.h.
- (void) addExtension: | (GPBExtensionDescriptor *) | extension | |
value: | (id) | value | |
Adds the given value to the extension for this message. This only applies to repeated field extensions. If the field is a repeated POD type, the value should be an NSNumber.
extension | The extension descriptor under which to add the value. |
value | The value to be added to the repeated extension. |
|
implementation |
- (void) clear |
Resets all of the fields of this message to their default values.
- (void) clearExtension: | (GPBExtensionDescriptor *) | extension |
Clears the given extension for this message.
extension | The extension descriptor to be cleared from this message. |
- (nullable NSData *) data |
Serializes the message to an NSData.
If there is an error while generating the data, nil is returned.
- (NSData *) delimitedData |
Serializes a varint with the message size followed by the message data, returning that as an NSData.
+ (GPBDescriptor *) descriptor |
- (GPBDescriptor *) descriptor |
Return the descriptor for the message.
- (NSArray *) extensionsCurrentlySet |
|
implementation |
- (nullable id) getExtension: | (GPBExtensionDescriptor *) | extension |
- (BOOL) hasExtension: | (GPBExtensionDescriptor *) | extension |
Checks whether there is an extension set on the message which matches the given extension descriptor.
extension | Extension descriptor to check if it's set on the message. |
- (nullable instancetype) initWithCodedInputStream: | (GPBCodedInputStream *) | input | |
extensionRegistry: | (nullable GPBExtensionRegistry *) | extensionRegistry | |
error: | (NSError **) | errorPtr | |
Initializes an instance by parsing the data from the given input stream. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
input | The stream to read data from. |
extensionRegistry | The extension registry to use to look up extensions. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
- (nullable instancetype) initWithData: | (NSData *) | data | |
error: | (NSError **) | errorPtr | |
Initializes an instance by parsing the data. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
data | The data to parse. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
- (nullable instancetype) initWithData: | (NSData *) | data | |
extensionRegistry: | (nullable GPBExtensionRegistry *) | extensionRegistry | |
error: | (NSError **) | errorPtr | |
Initializes an instance by parsing the data. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
data | The data to parse. |
extensionRegistry | The extension registry to use to look up extensions. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
|
implementation |
- (void) mergeFrom: | (GPBMessage *) | other |
Merges the fields from another message (of the same type) into this message.
other | Message to merge into this message. |
|
implementation |
- (void) mergeFromData: | (NSData *) | data | |
extensionRegistry: | (nullable GPBExtensionRegistry *) | extensionRegistry | |
Parses the given data as this message's class, and merges those values into this message.
data | The binary representation of the message to merge. |
extensionRegistry | The extension registry to use to look up extensions. |
GPBCodedInputStreamException | Exception thrown when parsing was unsuccessful. |
+ (instancetype) message |
+ (nullable instancetype) parseDelimitedFromCodedInputStream: | (GPBCodedInputStream *) | input | |
extensionRegistry: | (nullable GPBExtensionRegistry *) | extensionRegistry | |
error: | (NSError **) | errorPtr | |
Creates a new instance by parsing the data from the given input stream. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
input | The stream to read data from. |
extensionRegistry | The extension registry to use to look up extensions. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
+ (nullable instancetype) parseFromCodedInputStream: | (GPBCodedInputStream *) | input | |
extensionRegistry: | (nullable GPBExtensionRegistry *) | extensionRegistry | |
error: | (NSError **) | errorPtr | |
Creates a new instance by parsing the data from the given input stream. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
input | The stream to read data from. |
extensionRegistry | The extension registry to use to look up extensions. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
+ (nullable instancetype) parseFromData: | (NSData *) | data | |
error: | (NSError **) | errorPtr | |
Creates a new instance by parsing the provided data. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
data | The data to parse. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
+ (nullable instancetype) parseFromData: | (NSData *) | data | |
extensionRegistry: | (nullable GPBExtensionRegistry *) | extensionRegistry | |
error: | (NSError **) | errorPtr | |
Creates a new instance by parsing the data. This method should be sent to the generated message class that the data should be interpreted as. If there is an error the method returns nil and the error is returned in errorPtr (when provided).
data | The data to parse. |
extensionRegistry | The extension registry to use to look up extensions. |
errorPtr | An optional error pointer to fill in with a failure reason if the data can not be parsed. |
- (size_t) serializedSize |
Calculates the size of the object if it were serialized.
This is not a cached value. If you are following a pattern like this:
you would be better doing:
- (void) setExtension: | (GPBExtensionDescriptor *) | extension | |
index: | (NSUInteger) | index | |
value: | (id) | value | |
Replaces the value at the given index with the given value for the extension on this message. This only applies to repeated field extensions. If the field is a repeated POD type, the value is should be an NSNumber.
extension | The extension descriptor under which to replace the value. |
index | The index of the extension to be replaced. |
value | The value to be replaced in the repeated extension. |
- (void) setExtension: | (GPBExtensionDescriptor *) | extension | |
value: | (nullable id) | value | |
Sets the given extension's value for this message. This only applies for single field extensions (i.e. - not repeated fields).
Extensions use boxed values (NSNumbers).
extension | The extension descriptor under which to set the value. |
value | The value to be set as the extension. |
- (void) writeDelimitedToCodedOutputStream: | (GPBCodedOutputStream *) | output |
Writes out a varint for the message size followed by the message to the given output stream.
output | The coded output stream into which to write the message. |
- (void) writeDelimitedToOutputStream: | (NSOutputStream *) | output |
Writes out a varint for the message size followed by the message to the given output stream.
output | The output stream into which to write the message. |
- (void) writeToCodedOutputStream: | (GPBCodedOutputStream *) | output |
Writes out the message to the given coded output stream.
output | The coded output stream into which to write the message. |
- (void) writeToOutputStream: | (NSOutputStream *) | output |
Writes out the message to the given output stream.
output | The output stream into which to write the message. |
|
protected |
Definition at line 63 of file GPBMessage_PackagePrivate.h.
|
readnonatomicassign |
Whether the message, along with all submessages, have the required fields set. This is only applicable for files declared with "proto2" syntax, as there are no required fields for "proto3" syntax.
Definition at line 103 of file GPBMessage.h.
|
readwritenonatomiccopy |
The set of unknown fields for this message.
Only messages from proto files declared with "proto2" syntax support unknown fields. For "proto3" syntax, any unknown fields found while parsing are dropped.
Definition at line 96 of file GPBMessage.h.