Instance Methods | Class Methods | Protected Attributes | Properties | List of all members
GPBMessage Class Reference

#import <GPBMessage.h>

Inheritance diagram for GPBMessage:
Inheritance graph
[legend]

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
 
GPBUnknownFieldSetunknownFields
 

Detailed Description

Base class that each generated message subclasses from.

Note
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.
While the class support NSSecureCoding, if the message has any extensions, they will end up reloaded in 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.

Method Documentation

◆ addExtension:value:

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

Parameters
extensionThe extension descriptor under which to add the value.
valueThe value to be added to the repeated extension.

◆ addUnknownMapEntry:value:

- (void) addUnknownMapEntry: (int32_t)  fieldNum
value: (NSData *)  data 
implementation

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

Parameters
extensionThe extension descriptor to be cleared from this message.

◆ data

- (nullable NSData *) data

Serializes the message to an 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.
Returns
The binary representation of the message.

◆ delimitedData

- (NSData *) delimitedData

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

Note
This value is not cached, so if you are using it repeatedly, it is recommended to keep a local copy.
Returns
The binary representation of the size along with the message.

◆ descriptor [1/2]

+ (GPBDescriptor *) descriptor
Returns
The descriptor for the message class.

◆ descriptor [2/2]

- (GPBDescriptor *) descriptor

Return the descriptor for the message.

◆ extensionsCurrentlySet

- (NSArray *) extensionsCurrentlySet
Returns
An array with the extension descriptors that are currently set on the message.

◆ getExistingExtension:

- (id) getExistingExtension: (GPBExtensionDescriptor *)  extension
implementation

◆ getExtension:

- (nullable id) getExtension: (GPBExtensionDescriptor *)  extension

◆ hasExtension:

- (BOOL) hasExtension: (GPBExtensionDescriptor *)  extension

Checks whether there is an extension set on the message which matches the given extension descriptor.

Parameters
extensionExtension descriptor to check if it's set on the message.
Returns
Whether the extension is currently set on the message.

◆ initWithCodedInputStream:extensionRegistry:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
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
An initialized instance of the generated class.

◆ initWithData:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
Parameters
dataThe data to parse.
errorPtrAn optional error pointer to fill in with a failure reason if the data can not be parsed.
Returns
An initialized instance of the generated class.

◆ initWithData:extensionRegistry:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
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
An initialized instance of the generated class.

◆ mergeDelimitedFromCodedInputStream:extensionRegistry:

- (void) mergeDelimitedFromCodedInputStream: (GPBCodedInputStream *)  input
extensionRegistry: (GPBExtensionRegistry *)  extensionRegistry 
implementation

◆ mergeFrom:

- (void) mergeFrom: (GPBMessage *)  other

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

Parameters
otherMessage to merge into this message.

◆ mergeFromCodedInputStream:extensionRegistry:

- (void) mergeFromCodedInputStream: (GPBCodedInputStream *)  input
extensionRegistry: (GPBExtensionRegistry *)  extensionRegistry 
implementation

◆ mergeFromData:extensionRegistry:

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

Parses the given data as this message's class, and merges those values into this message.

Parameters
dataThe binary representation of the message to merge.
extensionRegistryThe extension registry to use to look up extensions.
Exceptions
GPBCodedInputStreamExceptionException thrown when parsing was unsuccessful.

◆ message

+ (instancetype) message
Returns
An autoreleased message with the default values set.

◆ parseDelimitedFromCodedInputStream:extensionRegistry:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
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 generated class.

◆ parseFromCodedInputStream:extensionRegistry:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
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 generated class.

◆ parseFromData:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
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 generated class.

◆ parseFromData:extensionRegistry:error:

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

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.
The errors returned are likely coming from the domain and codes listed at the top of this file and GPBCodedInputStream.h.
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 generated class.

◆ 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];
Returns
The size of the message in it's binary representation.

◆ setExtension:index:value:

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

Parameters
extensionThe extension descriptor under which to replace the value.
indexThe index of the extension to be replaced.
valueThe value to be replaced in the repeated extension.

◆ setExtension:value:

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

Parameters
extensionThe extension descriptor under which to set the value.
valueThe value to be set as the extension.

◆ writeDelimitedToCodedOutputStream:

- (void) writeDelimitedToCodedOutputStream: (GPBCodedOutputStream *)  output

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

Parameters
outputThe coded output stream into which to write the message.
Note
This can raise the GPBCodedOutputStreamException_* exceptions.

◆ writeDelimitedToOutputStream:

- (void) writeDelimitedToOutputStream: (NSOutputStream *)  output

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

Parameters
outputThe output stream into which to write the message.
Note
This can raise the GPBCodedOutputStreamException_* exceptions.

◆ writeToCodedOutputStream:

- (void) writeToCodedOutputStream: (GPBCodedOutputStream *)  output

Writes out the message to the given coded output stream.

Parameters
outputThe coded output stream into which to write the message.
Note
This can raise the GPBCodedOutputStreamException_* exceptions.

◆ writeToOutputStream:

- (void) writeToOutputStream: (NSOutputStream *)  output

Writes out the message to the given output stream.

Parameters
outputThe output stream into which to write the message.
Note
This can raise the GPBCodedOutputStreamException_* exceptions.

Member Data Documentation

◆ messageStorage_

- (package GPBMessage_StoragePtr) messageStorage_
protected

Definition at line 63 of file GPBMessage_PackagePrivate.h.

Property Documentation

◆ initialized

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

◆ unknownFields

- (GPBUnknownFieldSet*) unknownFields
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.


The documentation for this class was generated from the following file:
length
GLenum GLuint GLenum GLsizei length
Definition: glcorearb.h:2695
-[GPBMessage data]
nullable NSData * data()
foo
Definition: googletest-output-test_.cc:534
-[GPBMessage serializedSize]
size_t serializedSize()
size
#define size
Definition: glcorearb.h:2944
size
GLsizeiptr size
Definition: glcorearb.h:2943
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:05