protobuf-c 1.5.1
Protocol Buffers implementation in C
|
This is the public API for libprotobuf-c
.
These interfaces are stable and subject to Semantic Versioning guarantees.
Data Structures | |
struct | ProtobufCAllocator |
Structure for defining a custom memory allocator. More... | |
struct | ProtobufCBinaryData |
Structure for the protobuf bytes scalar type. More... | |
struct | ProtobufCBuffer |
Structure for defining a virtual append-only buffer. More... | |
struct | ProtobufCBufferSimple |
Simple buffer "subclass" of ProtobufCBuffer . More... | |
struct | ProtobufCEnumDescriptor |
Describes an enumeration as a whole, with all of its values. More... | |
struct | ProtobufCEnumValue |
Represents a single value of an enumeration. More... | |
struct | ProtobufCEnumValueIndex |
Used by ProtobufCEnumDescriptor to look up enum values. More... | |
struct | ProtobufCFieldDescriptor |
Describes a single field in a message. More... | |
struct | ProtobufCIntRange |
Helper structure for optimizing int => index lookups in the case where the keys are mostly consecutive values, as they presumably are for enums and fields. More... | |
struct | ProtobufCMessage |
An instance of a message. More... | |
struct | ProtobufCMessageDescriptor |
Describes a message. More... | |
struct | ProtobufCMessageUnknownField |
An unknown message field. More... | |
struct | ProtobufCMethodDescriptor |
Method descriptor. More... | |
struct | ProtobufCService |
Service. More... | |
struct | ProtobufCServiceDescriptor |
Service descriptor. More... | |
Macros | |
#define | PROTOBUF_C_VERSION "1.5.1" |
The version of the protobuf-c headers, represented as a string using the same format as protobuf_c_version(). | |
#define | PROTOBUF_C_VERSION_NUMBER 1005001 |
The version of the protobuf-c headers, represented as an integer using the same format as protobuf_c_version_number(). | |
#define | PROTOBUF_C_MIN_COMPILER_VERSION 1000000 |
The minimum protoc-gen-c version which works with the current version of the protobuf-c headers. | |
#define | PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } |
Message initialiser. | |
#define | PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) |
Initialise a ProtobufCBufferSimple object. | |
#define | PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) |
Clear a ProtobufCBufferSimple object, freeing any allocated memory. | |
Typedefs | |
typedef int | protobuf_c_boolean |
Boolean type. | |
typedef void(* | ProtobufCClosure) (const ProtobufCMessage *, void *closure_data) |
typedef void(* | ProtobufCMessageInit) (ProtobufCMessage *) |
typedef void(* | ProtobufCServiceDestroy) (ProtobufCService *) |
Enumerations | |
enum | ProtobufCFieldFlag |
Values for the flags word in ProtobufCFieldDescriptor . More... | |
enum | ProtobufCLabel |
Message field rules. More... | |
enum | ProtobufCType |
Field value types. More... | |
enum | ProtobufCWireType |
Field wire types. More... | |
Functions | |
const char * | protobuf_c_version (void) |
Get the version of the protobuf-c library. | |
uint32_t | protobuf_c_version_number (void) |
Get the version of the protobuf-c library. | |
const ProtobufCEnumValue * | protobuf_c_enum_descriptor_get_value_by_name (const ProtobufCEnumDescriptor *desc, const char *name) |
Look up a ProtobufCEnumValue from a ProtobufCEnumDescriptor by name. | |
const ProtobufCEnumValue * | protobuf_c_enum_descriptor_get_value (const ProtobufCEnumDescriptor *desc, int value) |
Look up a ProtobufCEnumValue from a ProtobufCEnumDescriptor by numeric value. | |
const ProtobufCFieldDescriptor * | protobuf_c_message_descriptor_get_field_by_name (const ProtobufCMessageDescriptor *desc, const char *name) |
Look up a ProtobufCFieldDescriptor from a ProtobufCMessageDescriptor by the name of the field. | |
const ProtobufCFieldDescriptor * | protobuf_c_message_descriptor_get_field (const ProtobufCMessageDescriptor *desc, unsigned value) |
Look up a ProtobufCFieldDescriptor from a ProtobufCMessageDescriptor by the tag value of the field. | |
size_t | protobuf_c_message_get_packed_size (const ProtobufCMessage *message) |
Determine the number of bytes required to store the serialised message. | |
size_t | protobuf_c_message_pack (const ProtobufCMessage *message, uint8_t *out) |
Serialise a message from its in-memory representation. | |
size_t | protobuf_c_message_pack_to_buffer (const ProtobufCMessage *message, ProtobufCBuffer *buffer) |
Serialise a message from its in-memory representation to a virtual buffer. | |
ProtobufCMessage * | protobuf_c_message_unpack (const ProtobufCMessageDescriptor *descriptor, ProtobufCAllocator *allocator, size_t len, const uint8_t *data) |
Unpack a serialised message into an in-memory representation. | |
void | protobuf_c_message_free_unpacked (ProtobufCMessage *message, ProtobufCAllocator *allocator) |
Free an unpacked message object. | |
protobuf_c_boolean | protobuf_c_message_check (const ProtobufCMessage *) |
Check the validity of a message object. | |
void | protobuf_c_message_init (const ProtobufCMessageDescriptor *descriptor, void *message) |
Initialise a message object from a message descriptor. | |
void | protobuf_c_service_destroy (ProtobufCService *service) |
Free a service. | |
const ProtobufCMethodDescriptor * | protobuf_c_service_descriptor_get_method_by_name (const ProtobufCServiceDescriptor *desc, const char *name) |
Look up a ProtobufCMethodDescriptor by name. | |
void | protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer, size_t len, const unsigned char *data) |
The append method for ProtobufCBufferSimple . | |
void | protobuf_c_service_generated_init (ProtobufCService *service, const ProtobufCServiceDescriptor *descriptor, ProtobufCServiceDestroy destroy) |
void | protobuf_c_service_invoke_internal (ProtobufCService *service, unsigned method_index, const ProtobufCMessage *input, ProtobufCClosure closure, void *closure_data) |
#define PROTOBUF_C_VERSION "1.5.1" |
The version of the protobuf-c headers, represented as a string using the same format as protobuf_c_version().
#define PROTOBUF_C_VERSION_NUMBER 1005001 |
The version of the protobuf-c headers, represented as an integer using the same format as protobuf_c_version_number().
#define PROTOBUF_C_MIN_COMPILER_VERSION 1000000 |
The minimum protoc-gen-c version which works with the current version of the protobuf-c headers.
#define PROTOBUF_C_MESSAGE_INIT | ( | descriptor | ) | { descriptor, 0, NULL } |
Message initialiser.
#define PROTOBUF_C_BUFFER_SIMPLE_INIT | ( | array_of_bytes | ) |
Initialise a ProtobufCBufferSimple
object.
#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR | ( | simp_buf | ) |
Clear a ProtobufCBufferSimple
object, freeing any allocated memory.
typedef int protobuf_c_boolean |
Boolean type.
enum ProtobufCFieldFlag |
Values for the flags
word in ProtobufCFieldDescriptor
.
enum ProtobufCLabel |
Message field rules.
enum ProtobufCType |
Field value types.
enum ProtobufCWireType |
Field wire types.
const char * protobuf_c_version | ( | void | ) |
Get the version of the protobuf-c library.
Note that this is the version of the library linked against, not the version of the headers compiled against.
uint32_t protobuf_c_version_number | ( | void | ) |
Get the version of the protobuf-c library.
Note that this is the version of the library linked against, not the version of the headers compiled against.
const ProtobufCEnumValue * protobuf_c_enum_descriptor_get_value_by_name | ( | const ProtobufCEnumDescriptor * | desc, |
const char * | name | ||
) |
Look up a ProtobufCEnumValue
from a ProtobufCEnumDescriptor
by name.
desc | The ProtobufCEnumDescriptor object. |
name | The name field from the corresponding ProtobufCEnumValue object to match. |
ProtobufCEnumValue
object. NULL | If not found or if the optimize_for = CODE_SIZE option was set. |
const ProtobufCEnumValue * protobuf_c_enum_descriptor_get_value | ( | const ProtobufCEnumDescriptor * | desc, |
int | value | ||
) |
Look up a ProtobufCEnumValue
from a ProtobufCEnumDescriptor
by numeric value.
desc | The ProtobufCEnumDescriptor object. |
value | The value field from the corresponding ProtobufCEnumValue object to match. |
ProtobufCEnumValue
object. NULL | If not found. |
const ProtobufCFieldDescriptor * protobuf_c_message_descriptor_get_field_by_name | ( | const ProtobufCMessageDescriptor * | desc, |
const char * | name | ||
) |
Look up a ProtobufCFieldDescriptor
from a ProtobufCMessageDescriptor
by the name of the field.
desc | The ProtobufCMessageDescriptor object. |
name | The name of the field. |
ProtobufCFieldDescriptor
object. NULL | If not found or if the optimize_for = CODE_SIZE option was set. |
const ProtobufCFieldDescriptor * protobuf_c_message_descriptor_get_field | ( | const ProtobufCMessageDescriptor * | desc, |
unsigned | value | ||
) |
Look up a ProtobufCFieldDescriptor
from a ProtobufCMessageDescriptor
by the tag value of the field.
desc | The ProtobufCMessageDescriptor object. |
value | The tag value of the field. |
ProtobufCFieldDescriptor
object. NULL | If not found. |
size_t protobuf_c_message_get_packed_size | ( | const ProtobufCMessage * | message | ) |
Determine the number of bytes required to store the serialised message.
message | The message object to serialise. |
size_t protobuf_c_message_pack | ( | const ProtobufCMessage * | message, |
uint8_t * | out | ||
) |
Serialise a message from its in-memory representation.
This function stores the serialised bytes of the message in a pre-allocated buffer.
message | The message object to serialise. | |
[out] | out | Buffer to store the bytes of the serialised message. This buffer must have enough space to store the packed message. Use protobuf_c_message_get_packed_size() to determine the number of bytes required. |
out
. size_t protobuf_c_message_pack_to_buffer | ( | const ProtobufCMessage * | message, |
ProtobufCBuffer * | buffer | ||
) |
Serialise a message from its in-memory representation to a virtual buffer.
This function calls the append
method of a ProtobufCBuffer
object to consume the bytes generated by the serialiser.
message | The message object to serialise. |
buffer | The virtual buffer object. |
ProtobufCMessage * protobuf_c_message_unpack | ( | const ProtobufCMessageDescriptor * | descriptor, |
ProtobufCAllocator * | allocator, | ||
size_t | len, | ||
const uint8_t * | data | ||
) |
Unpack a serialised message into an in-memory representation.
descriptor | The message descriptor. |
allocator | ProtobufCAllocator to use for memory allocation. May be NULL to specify the default allocator. |
len | Length in bytes of the serialised message. |
data | Pointer to the serialised message. |
NULL | If an error occurred during unpacking. |
void protobuf_c_message_free_unpacked | ( | ProtobufCMessage * | message, |
ProtobufCAllocator * | allocator | ||
) |
Free an unpacked message object.
This function should be used to deallocate the memory used by a call to protobuf_c_message_unpack().
message | The message object to free. May be NULL. |
allocator | ProtobufCAllocator to use for memory deallocation. May be NULL to specify the default allocator. |
protobuf_c_boolean protobuf_c_message_check | ( | const ProtobufCMessage * | ) |
Check the validity of a message object.
Makes sure all required fields (PROTOBUF_C_LABEL_REQUIRED
) are present. Recursively checks nested messages.
TRUE | Message is valid. |
FALSE | Message is invalid. |
void protobuf_c_message_init | ( | const ProtobufCMessageDescriptor * | descriptor, |
void * | message | ||
) |
Initialise a message object from a message descriptor.
descriptor | Message descriptor. |
message | Allocated block of memory of size descriptor->sizeof_message . |
void protobuf_c_service_destroy | ( | ProtobufCService * | service | ) |
Free a service.
service | The service object to free. |
const ProtobufCMethodDescriptor * protobuf_c_service_descriptor_get_method_by_name | ( | const ProtobufCServiceDescriptor * | desc, |
const char * | name | ||
) |
Look up a ProtobufCMethodDescriptor
by name.
desc | Service descriptor. |
name | Name of the method. |
ProtobufCMethodDescriptor
object. NULL | If not found or if the optimize_for = CODE_SIZE option was set. |
void protobuf_c_buffer_simple_append | ( | ProtobufCBuffer * | buffer, |
size_t | len, | ||
const unsigned char * | data | ||
) |
The append
method for ProtobufCBufferSimple
.
buffer | The buffer object to append to. Must actually be a ProtobufCBufferSimple object. |
len | Number of bytes in data . |
data | Data to append. |