webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Instance Methods | Class Methods | Properties | List of all members
GPBMessage Class Reference

Base class for all of the generated message classes. More...

#import <GPBMessage.h>

Inheritance diagram for GPBMessage:
NSObject GPBAny GPBApi GPBBoolValue GPBBytesValue GPBDoubleValue GPBDuration GPBEmpty GPBEnum GPBEnumValue GPBField GPBFieldMask GPBFloatValue GPBInt32Value GPBInt64Value GPBListValue GPBMethod GPBMixin GPBOption GPBSourceContext GPBStringValue GPBStruct GPBTimestamp GPBType GPBUInt32Value GPBUInt64Value GPBValue

Instance Methods

(instancetype) - initWithData:error:
 
(instancetype) - initWithData:extensionRegistry:error:
 
(instancetype) - initWithCodedInputStream:extensionRegistry:error:
 
(void- writeToCodedOutputStream:
 Writes out the message to the given output stream. More...
 
(void- writeToOutputStream:
 Writes out the message to the given output stream. More...
 
(void- writeDelimitedToCodedOutputStream:
 
(void- writeDelimitedToOutputStream:
 
(nullable NSData *) - data
 
(NSData *) - delimitedData
 
(size_t- serializedSize
 
(GPBDescriptor *) - descriptor
 Return the descriptor for the message. More...
 
(BOOL- hasExtension:
 Test to see if the given extension is set on the message. More...
 
(nullable id- getExtension:
 
(void- setExtension:value:
 
(void- addExtension:value:
 
(void- setExtension:index:value:
 
(void- clearExtension:
 Clears the given extension for this message. More...
 
(void- clear
 Resets all of the fields of this message to their default values. More...
 
(void- mergeFromData:extensionRegistry:
 
(void- mergeFrom:
 

Class Methods

(instancetype) + message
 Returns an autoreleased instance. More...
 
(instancetype) + parseFromData:error:
 
(instancetype) + parseFromData:extensionRegistry:error:
 
(instancetype) + parseFromCodedInputStream:extensionRegistry:error:
 
(instancetype) + parseDelimitedFromCodedInputStream:extensionRegistry:error:
 
(GPBDescriptor *) + descriptor
 Return the descriptor for the message class. More...
 

Properties

GPBUnknownFieldSetunknownFields
 
BOOL initialized
 Are all required fields set in the message and all embedded messages. More...
 

Detailed Description

Base class for all of the generated message classes.

Method Documentation

◆ addExtension:value:()

- (void) addExtension: (GPBExtensionDescriptor *)  extension
value: (id value 

Adds the given value to the extension for this message. This is only for repeated field extensions. If the field is a repeated POD type the value is a NSNumber.

◆ clear()

- (void) clear

Resets all of the fields of this message to their default values.

◆ clearExtension:()

- (void) clearExtension: (GPBExtensionDescriptor *)  extension

Clears the given extension for this message.

◆ data()

- (NSData *) data

Serializes the message to a NSData.

If there is an error while generating the data, nil is returned.

Note
This value is not cached, so if you are using it repeatedly, cache it yourself.
In DEBUG ONLY, the message is also checked for all required field, if one is missing, nil will be returned.

◆ delimitedData()

- (NSData *) delimitedData

Serializes a varint with the message size followed by the message data, returning that as a NSData.

Note
This value is not cached, so if you are using it repeatedly, cache it yourself.

◆ descriptor() [1/2]

- (GPBDescriptor *) descriptor

Return the descriptor for the message.

◆ descriptor() [2/2]

+ (GPBDescriptor *) descriptor

Return the descriptor for the message class.

◆ getExtension:()

- (id) getExtension: (GPBExtensionDescriptor *)  extension

Fetches the given extension's value for this message.

Extensions use boxed values (NSNumbers) for PODs and NSMutableArrays for repeated fields. If the extension is a Message one will be auto created for you and returned similar to fields.

◆ hasExtension:()

- (BOOL) hasExtension: (GPBExtensionDescriptor *)  extension

Test to see if the given extension is set on the message.

◆ initWithCodedInputStream:extensionRegistry:error:()

- (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).

Note
Unlike the parseFrom... methods, this never checks to see if all of the required fields are set. So this method can be used to reload messages that may not be complete.
Parameters
inputThe stream to read data from.
extensionRegistryThe extension registry to use to look up extensions.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.

◆ initWithData:error:()

- (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).

Note
In DEBUG builds, the parsed message is checked to be sure all required fields were provided, and the parse will fail if some are missing.
Parameters
dataThe data to parse.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.

◆ initWithData:extensionRegistry:error:()

- (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).

Note
In DEBUG builds, the parsed message is checked to be sure all required fields were provided, and the parse will fail if some are missing.
Parameters
dataThe data to parse.
extensionRegistryThe extension registry to use to look up extensions.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.

◆ mergeFrom:()

- (void) mergeFrom: (GPBMessage *)  other

Merges the fields from another message (of the same type) into this message.

◆ mergeFromData:extensionRegistry:()

- (void) mergeFromData: (NSData *)  data
extensionRegistry: (nullable GPBExtensionRegistry *)  extensionRegistry 

Parses a message of this type from the input and merges it with this message.

Note
This will throw if there is an error parsing the data.

◆ message()

+ (instancetype) message

Returns an autoreleased instance.

◆ parseDelimitedFromCodedInputStream:extensionRegistry:error:()

+ (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).

Note
Unlike the parseFrom... methods, this never checks to see if all of the required fields are set. So this method can be used to reload messages that may not be complete.
Parameters
inputThe stream to read data from.
extensionRegistryThe extension registry to use to look up extensions.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.
Returns
A new instance of the class messaged.

◆ parseFromCodedInputStream:extensionRegistry:error:()

+ (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).

Note
In DEBUG builds, the parsed message is checked to be sure all required fields were provided, and the parse will fail if some are missing.
Parameters
inputThe stream to read data from.
extensionRegistryThe extension registry to use to look up extensions.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.
Returns
A new instance of the class messaged.

◆ parseFromData:error:()

+ (instancetype) parseFromData: (NSData *)  data
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).

Note
In DEBUG builds, the parsed message is checked to be sure all required fields were provided, and the parse will fail if some are missing.
Parameters
dataThe data to parse.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.
Returns
A new instance of the class messaged.

◆ parseFromData:extensionRegistry:error:()

+ (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).

Note
In DEBUG builds, the parsed message is checked to be sure all required fields were provided, and the parse will fail if some are missing.
Parameters
dataThe data to parse.
extensionRegistryThe extension registry to use to look up extensions.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.
Returns
A new instance of the class messaged.

◆ serializedSize()

- (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:

size_t size = [aMsg serializedSize];
NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
[foo writeSize:size];
[foo appendData:[aMsg data]];

you would be better doing:

NSData *data = [aMsg data];
NSUInteger size = [aMsg length];
NSMutableData *foo = [NSMutableData dataWithCapacity:size + sizeof(size)];
[foo writeSize:size];
[foo appendData:data];

◆ setExtension:index:value:()

- (void) setExtension: (GPBExtensionDescriptor *)  extension
index: (NSUInteger)  index
value: (id value 

Replaces the given value at an index for the extension on this message. This is only for repeated field extensions. If the field is a repeated POD type the value is a NSNumber.

◆ setExtension:value:()

- (void) setExtension: (GPBExtensionDescriptor *)  extension
value: (nullable id value 

Sets the given extension's value for this message. This is only for single field extensions (i.e. - not repeated fields).

Extensions use boxed values (NSNumbers).

◆ writeDelimitedToCodedOutputStream:()

- (void) writeDelimitedToCodedOutputStream: (GPBCodedOutputStream *)  output

Writes out a varint for the message size followed by the the message to the given output stream.

◆ writeDelimitedToOutputStream:()

- (void) writeDelimitedToOutputStream: (NSOutputStream *)  output

Writes out a varint for the message size followed by the the message to the given output stream.

◆ writeToCodedOutputStream:()

- (void) writeToCodedOutputStream: (GPBCodedOutputStream *)  output

Writes out the message to the given output stream.

◆ writeToOutputStream:()

- (void) writeToOutputStream: (NSOutputStream *)  output

Writes out the message to the given output stream.

Property Documentation

◆ initialized

- (BOOL) initialized
readnonatomicassign

Are all required fields set in the message and all embedded messages.

◆ unknownFields

- (GPBUnknownFieldSet *) unknownFields
readwritenonatomiccopy

The 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.


The documentation for this class was generated from the following files: