zCm 0.1.0
Lightweight messaging toolkit
Loading...
Searching...
No Matches
zcm_msg.h File Reference

Typed message builder/parser API for zCm payloads.

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  zcm_msg_value
 Decoded standardized scalar value extracted from a message. More...

Typedefs

typedef struct zcm_msg zcm_msg_t
 Opaque typed message container.
typedef struct zcm_msg_value zcm_msg_value_t
 Decoded standardized scalar value extracted from a message.

Enumerations

enum  zcm_msg_item_type_t {
  ZCM_MSG_ITEM_CHAR = 1 , ZCM_MSG_ITEM_SHORT = 2 , ZCM_MSG_ITEM_INT = 3 , ZCM_MSG_ITEM_LONG = 4 ,
  ZCM_MSG_ITEM_FLOAT = 5 , ZCM_MSG_ITEM_DOUBLE = 6 , ZCM_MSG_ITEM_ARRAY = 7 , ZCM_MSG_ITEM_TEXT = 8 ,
  ZCM_MSG_ITEM_BYTES = 9
}
 Encoded item kind stored in a message payload. More...
enum  zcm_msg_array_type_t {
  ZCM_MSG_ARRAY_CHAR = 1 , ZCM_MSG_ARRAY_SHORT = 2 , ZCM_MSG_ARRAY_INT = 3 , ZCM_MSG_ARRAY_FLOAT = 4 ,
  ZCM_MSG_ARRAY_DOUBLE = 5
}
 Element type for array payload items. More...
enum  zcm_msg_status_t {
  ZCM_MSG_OK = 0 , ZCM_MSG_ERR = -1 , ZCM_MSG_ERR_TYPE = -2 , ZCM_MSG_ERR_RANGE = -3 ,
  ZCM_MSG_ERR_FORMAT = -4
}
 Status/error codes returned by zcm_msg APIs. More...
enum  zcm_msg_value_kind_t { ZCM_MSG_VALUE_TEXT = 1 , ZCM_MSG_VALUE_DOUBLE = 2 , ZCM_MSG_VALUE_FLOAT = 3 , ZCM_MSG_VALUE_INT = 4 }
 Canonical scalar kind used by the standardized value property. More...

Functions

zcm_msg_tzcm_msg_new (void)
 Allocate a new empty message.
void zcm_msg_free (zcm_msg_t *msg)
 Free a message allocated by zcm_msg_new().
void zcm_msg_reset (zcm_msg_t *msg)
 Clear payload, type name, and read cursor of a message.
void zcm_msg_rewind (zcm_msg_t *msg)
 Reset only the payload read cursor to the beginning.
int zcm_msg_set_type (zcm_msg_t *msg, const char *type)
 Set application-level message type string.
const char * zcm_msg_get_type (const zcm_msg_t *msg)
 Get the message type string.
int zcm_msg_put_char (zcm_msg_t *msg, char value)
 Append a char item.
int zcm_msg_put_short (zcm_msg_t *msg, int16_t value)
 Append a 16-bit signed integer item.
int zcm_msg_put_int (zcm_msg_t *msg, int32_t value)
 Append a 32-bit signed integer item.
int zcm_msg_put_long (zcm_msg_t *msg, int64_t value)
 Append a 64-bit signed integer item.
int zcm_msg_put_float (zcm_msg_t *msg, float value)
 Append a float item.
int zcm_msg_put_double (zcm_msg_t *msg, double value)
 Append a double item.
int zcm_msg_put_text (zcm_msg_t *msg, const char *value)
 Append a UTF-8 or ASCII text item.
int zcm_msg_put_bytes (zcm_msg_t *msg, const void *data, uint32_t len)
 Append an opaque byte buffer item.
int zcm_msg_put_array (zcm_msg_t *msg, zcm_msg_array_type_t type, uint32_t elements, const void *data)
 Append an array item.
int zcm_msg_put_value_text (zcm_msg_t *msg, const char *value)
 Append the standardized scalar value as text.
int zcm_msg_put_value_double (zcm_msg_t *msg, double value)
 Append the standardized scalar value as double.
int zcm_msg_put_value_float (zcm_msg_t *msg, float value)
 Append the standardized scalar value as float.
int zcm_msg_put_value_int (zcm_msg_t *msg, int32_t value)
 Append the standardized scalar value as int.
int zcm_msg_get_char (zcm_msg_t *msg, char *value)
 Read the next char item.
int zcm_msg_get_short (zcm_msg_t *msg, int16_t *value)
 Read the next 16-bit signed integer item.
int zcm_msg_get_int (zcm_msg_t *msg, int32_t *value)
 Read the next 32-bit signed integer item.
int zcm_msg_get_long (zcm_msg_t *msg, int64_t *value)
 Read the next 64-bit signed integer item.
int zcm_msg_get_float (zcm_msg_t *msg, float *value)
 Read the next float item.
int zcm_msg_get_double (zcm_msg_t *msg, double *value)
 Read the next double item.
int zcm_msg_get_text (zcm_msg_t *msg, const char **value, uint32_t *len)
 Read the next text item.
int zcm_msg_get_bytes (zcm_msg_t *msg, const void **data, uint32_t *len)
 Read the next raw byte item.
int zcm_msg_get_array (zcm_msg_t *msg, zcm_msg_array_type_t *type, uint32_t *elements, const void **data)
 Read the next array item.
int zcm_msg_get_value (zcm_msg_t *msg, zcm_msg_value_t *out)
 Decode the standardized scalar value from the current read offset.
const void * zcm_msg_data (const zcm_msg_t *msg, size_t *len)
 Get raw payload bytes (without transport envelope).
size_t zcm_msg_remaining (const zcm_msg_t *msg)
 Get unread payload bytes remaining from current read cursor.
int zcm_msg_from_bytes (zcm_msg_t *msg, const void *data, size_t len)
 Load message state from serialized envelope bytes.
int zcm_msg_validate (const zcm_msg_t *msg)
 Validate encoded payload structure.
const char * zcm_msg_last_error (const zcm_msg_t *msg)
 Get the last decode/validation error text for a message.