zCm 0.1.0
Lightweight messaging toolkit
Loading...
Searching...
No Matches
zcm_msg.h
Go to the documentation of this file.
1#ifndef ZCM_ZCM_MSG_H
2#define ZCM_ZCM_MSG_H
3
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <stddef.h>
14#include <stdint.h>
15
19
21typedef struct zcm_msg zcm_msg_t;
22
26typedef enum {
27 ZCM_MSG_ITEM_CHAR = 1,
28 ZCM_MSG_ITEM_SHORT = 2,
29 ZCM_MSG_ITEM_INT = 3,
30 ZCM_MSG_ITEM_LONG = 4,
31 ZCM_MSG_ITEM_FLOAT = 5,
32 ZCM_MSG_ITEM_DOUBLE = 6,
33 ZCM_MSG_ITEM_ARRAY = 7,
34 ZCM_MSG_ITEM_TEXT = 8,
35 ZCM_MSG_ITEM_BYTES = 9
37
41typedef enum {
42 ZCM_MSG_ARRAY_CHAR = 1,
43 ZCM_MSG_ARRAY_SHORT = 2,
44 ZCM_MSG_ARRAY_INT = 3,
45 ZCM_MSG_ARRAY_FLOAT = 4,
46 ZCM_MSG_ARRAY_DOUBLE = 5
48
52typedef enum {
53 ZCM_MSG_OK = 0,
54 ZCM_MSG_ERR = -1,
55 ZCM_MSG_ERR_TYPE = -2,
56 ZCM_MSG_ERR_RANGE = -3,
57 ZCM_MSG_ERR_FORMAT = -4
59
63typedef enum {
64 ZCM_MSG_VALUE_TEXT = 1,
65 ZCM_MSG_VALUE_DOUBLE = 2,
66 ZCM_MSG_VALUE_FLOAT = 3,
67 ZCM_MSG_VALUE_INT = 4
69
73typedef struct zcm_msg_value {
77 const char *text;
79 uint32_t text_len;
81 double d;
83 float f;
85 int32_t i;
87
94
101
108
115
123int zcm_msg_set_type(zcm_msg_t *msg, const char *type);
124
131const char *zcm_msg_get_type(const zcm_msg_t *msg);
132
140int zcm_msg_put_char(zcm_msg_t *msg, char value);
141
149int zcm_msg_put_short(zcm_msg_t *msg, int16_t value);
150
158int zcm_msg_put_int(zcm_msg_t *msg, int32_t value);
159
167int zcm_msg_put_long(zcm_msg_t *msg, int64_t value);
168
176int zcm_msg_put_float(zcm_msg_t *msg, float value);
177
185int zcm_msg_put_double(zcm_msg_t *msg, double value);
186
194int zcm_msg_put_text(zcm_msg_t *msg, const char *value);
195
204int zcm_msg_put_bytes(zcm_msg_t *msg, const void *data, uint32_t len);
205
216 uint32_t elements, const void *data);
217
225int zcm_msg_put_value_text(zcm_msg_t *msg, const char *value);
226
234int zcm_msg_put_value_double(zcm_msg_t *msg, double value);
235
243int zcm_msg_put_value_float(zcm_msg_t *msg, float value);
244
252int zcm_msg_put_value_int(zcm_msg_t *msg, int32_t value);
253
261int zcm_msg_get_char(zcm_msg_t *msg, char *value);
262
270int zcm_msg_get_short(zcm_msg_t *msg, int16_t *value);
271
279int zcm_msg_get_int(zcm_msg_t *msg, int32_t *value);
280
288int zcm_msg_get_long(zcm_msg_t *msg, int64_t *value);
289
297int zcm_msg_get_float(zcm_msg_t *msg, float *value);
298
306int zcm_msg_get_double(zcm_msg_t *msg, double *value);
307
318int zcm_msg_get_text(zcm_msg_t *msg, const char **value, uint32_t *len);
319
330int zcm_msg_get_bytes(zcm_msg_t *msg, const void **data, uint32_t *len);
331
344 uint32_t *elements, const void **data);
345
356
364const void *zcm_msg_data(const zcm_msg_t *msg, size_t *len);
365
372size_t zcm_msg_remaining(const zcm_msg_t *msg);
373
382int zcm_msg_from_bytes(zcm_msg_t *msg, const void *data, size_t len);
383
391
398const char *zcm_msg_last_error(const zcm_msg_t *msg);
399
401
402#ifdef __cplusplus
403}
404#endif
405
406#endif /* ZCM_ZCM_MSG_H */
int zcm_msg_get_char(zcm_msg_t *msg, char *value)
Read the next char item.
int zcm_msg_put_value_float(zcm_msg_t *msg, float value)
Append the standardized scalar value as float.
void zcm_msg_free(zcm_msg_t *msg)
Free a message allocated by zcm_msg_new().
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_put_float(zcm_msg_t *msg, float value)
Append a float item.
int zcm_msg_get_double(zcm_msg_t *msg, double *value)
Read the next double item.
int zcm_msg_put_char(zcm_msg_t *msg, char value)
Append a char item.
int zcm_msg_put_int(zcm_msg_t *msg, int32_t value)
Append a 32-bit signed integer item.
struct zcm_msg zcm_msg_t
Opaque typed message container.
Definition zcm_msg.h:21
int zcm_msg_put_value_text(zcm_msg_t *msg, const char *value)
Append the standardized scalar value as text.
int zcm_msg_get_float(zcm_msg_t *msg, float *value)
Read the next float item.
int zcm_msg_put_bytes(zcm_msg_t *msg, const void *data, uint32_t len)
Append an opaque byte buffer item.
zcm_msg_t * zcm_msg_new(void)
Allocate a new empty message.
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_int(zcm_msg_t *msg, int32_t value)
Append the standardized scalar value as int.
int zcm_msg_validate(const zcm_msg_t *msg)
Validate encoded payload structure.
struct zcm_msg_value zcm_msg_value_t
Decoded standardized scalar value extracted from a message.
const void * zcm_msg_data(const zcm_msg_t *msg, size_t *len)
Get raw payload bytes (without transport envelope).
zcm_msg_array_type_t
Element type for array payload items.
Definition zcm_msg.h:41
int zcm_msg_put_double(zcm_msg_t *msg, double value)
Append a double item.
int zcm_msg_put_value_double(zcm_msg_t *msg, double value)
Append the standardized scalar value as double.
int zcm_msg_put_long(zcm_msg_t *msg, int64_t value)
Append a 64-bit signed integer item.
zcm_msg_status_t
Status/error codes returned by zcm_msg APIs.
Definition zcm_msg.h:52
zcm_msg_item_type_t
Encoded item kind stored in a message payload.
Definition zcm_msg.h:26
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.
int zcm_msg_get_value(zcm_msg_t *msg, zcm_msg_value_t *out)
Decode the standardized scalar value from the current read offset.
void zcm_msg_reset(zcm_msg_t *msg)
Clear payload, type name, and read cursor of a message.
int zcm_msg_get_short(zcm_msg_t *msg, int16_t *value)
Read the next 16-bit signed integer item.
const char * zcm_msg_get_type(const zcm_msg_t *msg)
Get the message type string.
int zcm_msg_put_short(zcm_msg_t *msg, int16_t value)
Append a 16-bit signed integer 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_int(zcm_msg_t *msg, int32_t *value)
Read the next 32-bit signed integer item.
int zcm_msg_put_text(zcm_msg_t *msg, const char *value)
Append a UTF-8 or ASCII text 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_text(zcm_msg_t *msg, const char **value, uint32_t *len)
Read the next text item.
const char * zcm_msg_last_error(const zcm_msg_t *msg)
Get the last decode/validation error text for a message.
zcm_msg_value_kind_t
Canonical scalar kind used by the standardized value property.
Definition zcm_msg.h:63
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.
size_t zcm_msg_remaining(const zcm_msg_t *msg)
Get unread payload bytes remaining from current read cursor.
Decoded standardized scalar value extracted from a message.
Definition zcm_msg.h:73
const char * text
Text value pointer for ZCM_MSG_VALUE_TEXT (message-owned).
Definition zcm_msg.h:77
int32_t i
Integer value for ZCM_MSG_VALUE_INT.
Definition zcm_msg.h:85
double d
Double value for ZCM_MSG_VALUE_DOUBLE.
Definition zcm_msg.h:81
float f
Float value for ZCM_MSG_VALUE_FLOAT.
Definition zcm_msg.h:83
zcm_msg_value_kind_t kind
Value kind.
Definition zcm_msg.h:75
uint32_t text_len
Text length in bytes for text.
Definition zcm_msg.h:79