UM C API
6.16.1
|
Ultra Messaging (UM) Pre-Defined Message (PDM) API. The "lbmpdm.h" header file defines the APIs to create and parse Pre-Defined Messages (PDM). The binary code is contained in the "lbm" library (dynamic on Unix: "liblbm.so", static on Unix: "liblbm.a", dynamic only on Windows: "lbm.dll"). There are also Java and .NET APIs. See Pre-Defined Messages for general information on PDM. See UM C API for general information on the C API. See Fundamental Concepts for an introduction to Ultra Messaging. More...
#include <stdlib.h>
#include <inttypes.h>
Go to the source code of this file.
Data Structures | |
struct | lbmpdm_decimal_t |
Structure to hold a scaled decimal number. A scaled decimal number consists of a mantissa and an exponent . It represents the value . More... | |
struct | lbmpdm_timestamp_t |
Structure to hold a timestamp value. More... | |
struct | lbmpdm_field_info_attr_stct_t |
Attribute struct to be passed along with the name when adding field info to a definition. More... | |
struct | lbmpdm_field_value_stct_t |
Field value struct that can be populated with a field value when passed to the lbmpdm_msg_get_field_value_stct function. More... | |
Typedefs | |
typedef int32_t | lbmpdm_field_handle_t |
Type representing a handle to a message field. Field handles are returned when adding a field to a definition, or can be retrieved from a definition using the lbmpdm_get_field_handle_by_str_name or lbpdm_get_field_handle_by_int_name functions. | |
typedef struct lbmpdm_msg_stct_t | lbmpdm_msg_t |
Structure to hold a pdm message. | |
typedef struct lbmpdm_defn_stct_t | lbmpdm_defn_t |
Structure to hold a pdm definition. | |
typedef struct lbmpdm_field_info_attr_stct_t | lbmpdm_field_info_attr_t |
typedef struct lbmpdm_field_value_stct_t | lbmpdm_field_value_t |
typedef struct lbmpdm_iter_stct_t | lbmpdm_iter_t |
Iterator structure that is used to traverse the fields of a message. | |
Functions | |
LBMPDMExpDLL int | lbmpdm_errnum () |
Return the error number last encountered by this thread. More... | |
LBMPDMExpDLL const char * | lbmpdm_errmsg () |
Return an ASCII string containing the error message last encountered by this thread. More... | |
LBMPDMExpDLL int | lbmpdm_cache_init (uint32_t cache_size) |
initialize the cache for a given number of buckets. If 0 is given the the cache will default. The default can be altered via a PDM attribute. More... | |
LBMPDMExpDLL int | lbmpdm_cache_struct_add (lbmpdm_defn_t *defn) |
add a definition structure to the cache. It is assumed that the structure has a unique id, if the id is set to zero the structure will not be inserted into the map. More... | |
LBMPDMExpDLL int | lbmpdm_cache_struct_remove (int32_t id) |
delete a definition structure from the cache. Does not error if the structure doesn't exist. More... | |
LBMPDMExpDLL int | lbmpdm_cache_struct_remove_by_version (int32_t id, uint8_t vers_major, uint8_t vers_minor) |
delete a definition structure from the cache by its id and version. Does not error if the structure doesn't exist. More... | |
LBMPDMExpDLL int | lbmpdm_cache_struct_find (lbmpdm_defn_t **defn, int32_t id) |
find a given definition structure by id and return the structure for it. Returns PDM_FAILURE for nothing found, and PDM_SUCCESS for something found. Note, since a structure with the id of 0 won't exist in the cache you will never find one being returned from this find with an id of 0. More... | |
LBMPDMExpDLL int | lbmpdm_cache_struct_find_by_version (lbmpdm_defn_t **defn, int32_t id, uint8_t vers_major, uint8_t vers_minor) |
find a given definition structure by id, major version, and minor version and return the structure for it. Returns PDM_FAILURE for nothing found, and PDM_SUCCESS for something found. Note, since a structure with the id of 0 won't exist in the cache you will never find one being returned from this find with an id of 0. More... | |
LBMPDMExpDLL int | lbmpdm_cache_clear_all () |
nuke the whole cache, this deletes all the structures within the cache as well. | |
LBMPDMExpDLL lbmpdm_field_handle_t | lbmpdm_defn_get_field_handle_by_str_name (lbmpdm_defn_t *defn, const char *str_name) |
Retrieve a field handle from a definition via name. More... | |
LBMPDMExpDLL lbmpdm_field_handle_t | lbmpdm_defn_get_field_handle_by_int_name (lbmpdm_defn_t *defn, int32_t int_name) |
Retrieve a field handle from a definition via name. More... | |
LBMPDMExpDLL int | lbmpdm_defn_create (lbmpdm_defn_t **defn, int32_t num_fields, int32_t id, int8_t vrs_mjr, int8_t vrs_mnr, uint8_t field_names_type) |
Create a definition, with the passed number of fields. The num_fields is required to be at least 1. The number of fields can grow beyond this value, it is used initially to size the internal field info array. More... | |
LBMPDMExpDLL int | lbmpdm_defn_delete (lbmpdm_defn_t *defn) |
delete a given definition. More... | |
LBMPDMExpDLL int | lbmpdm_defn_finalize (lbmpdm_defn_t *defn) |
make this definition final. This needs to be done before using it in a message. More... | |
LBMPDMExpDLL lbmpdm_field_handle_t | lbmpdm_defn_add_field_info_by_str_name (lbmpdm_defn_t *defn, const char *str_name, int16_t type, lbmpdm_field_info_attr_t *info_attr) |
adds field info to the definition by string name More... | |
LBMPDMExpDLL lbmpdm_field_handle_t | lbmpdm_defn_add_field_info_by_int_name (lbmpdm_defn_t *defn, int32_t int_name, int16_t type, lbmpdm_field_info_attr_t *info_attr) |
adds field info to the definition by integer name More... | |
LBMPDMExpDLL uint32_t | lbmpdm_defn_get_length (lbmpdm_defn_t *defn) |
Gets the exact length of the serialized defn. This can be used to allocate a buffer of the exact length needed to serialize the defn. More... | |
LBMPDMExpDLL int32_t | lbmpdm_defn_get_id (lbmpdm_defn_t *defn) |
Gets the id of the definition. More... | |
LBMPDMExpDLL int32_t | lbmpdm_defn_get_num_fields (lbmpdm_defn_t *defn) |
Gets the number of fields in the definition. More... | |
LBMPDMExpDLL int8_t | lbmpdm_defn_get_msg_vers_major (lbmpdm_defn_t *defn) |
Gets the message major version number from the definition. More... | |
LBMPDMExpDLL int8_t | lbmpdm_defn_get_msg_vers_minor (lbmpdm_defn_t *defn) |
Gets the message minor version number from the definition. More... | |
LBMPDMExpDLL uint8_t | lbmpdm_defn_get_field_names_type (lbmpdm_defn_t *defn) |
Gets the field names type (either PDM_DEFN_STR_FIELD_NAMES or PDM_DEFN_INT_FIELD_NAMES) from the definition. More... | |
LBMPDMExpDLL uint8_t | lbmpdm_defn_is_finalized (lbmpdm_defn_t *defn) |
Gets whether or not the definition has been finalized (either PDM_TRUE or PDM_FALSE). More... | |
LBMPDMExpDLL const char * | lbmpdm_defn_get_field_info_str_name (lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle) |
Gets the string field name from a given definition's field handle. More... | |
LBMPDMExpDLL int32_t | lbmpdm_defn_get_field_info_int_name (lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle) |
Gets the integer field name from a given definition's field handle. More... | |
LBMPDMExpDLL int16_t | lbmpdm_defn_get_field_info_type (lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle) |
Gets the PDM field type from a given definition's field handle. More... | |
LBMPDMExpDLL int | lbmpdm_defn_serialize (lbmpdm_defn_t *defn, char *buffer, uint32_t *defn_len) |
Serialize a defn to a buffer. In normal usage this is not needed as the defn is either known in advance or sent as part of a message. The defn that is passed in is serialized into the caller's supplied buffer. More... | |
LBMPDMExpDLL int | lbmpdm_defn_deserialize (lbmpdm_defn_t *defn, const char *bufptr, uint32_t buflen, uint8_t swap_bytes) |
Deserialize the associated buffer into a newly created defn. More... | |
LBMPDMExpDLL int | lbmpdm_msg_create (lbmpdm_msg_t **message, lbmpdm_defn_t *defn, uint32_t flags) |
creates a message with the specified definition More... | |
LBMPDMExpDLL int | lbmpdm_msg_delete (lbmpdm_msg_t *message) |
Delete an lbmpdm_msg_t object and all associated resources (except the defn) This deletes a previously created PDM message and all resources associated with the message. More... | |
LBMPDMExpDLL int | lbmpdm_msg_and_defn_delete (lbmpdm_msg_t *message) |
Delete an lbmpdm_msg_t object and all associated resources (including the defn) This deletes a previously created PDM message and all resources associated with the message. More... | |
LBMPDMExpDLL uint32_t | lbmpdm_msg_get_length (const lbmpdm_msg_t *message) |
Gets the exact length of the serialized message. This can be used to allocate a buffer of the exact length needed to serialize the message. More... | |
LBMPDMExpDLL lbmpdm_defn_t * | lbmpdm_msg_get_defn (const lbmpdm_msg_t *message) |
Gets a pointer to the message definition. More... | |
LBMPDMExpDLL uint8_t | lbmpdm_msg_is_field_set (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle) |
Gets whether or not the field value has been set. More... | |
LBMPDMExpDLL int | lbmpdm_msg_get_field_value_stct (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, lbmpdm_field_value_t *field_value) |
Populates a field value struct with the value from the message. More... | |
LBMPDMExpDLL int | lbmpdm_msg_get_field_value (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t *len) |
Gets a field value from the message. More... | |
LBMPDMExpDLL int | lbmpdm_msg_get_field_value_vec (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len[], size_t *num_arr_elem) |
Gets an array of field values from the message. More... | |
LBMPDMExpDLL int | lbmpdm_msg_set_field_value (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len) |
Sets a field value in a message. More... | |
LBMPDMExpDLL int | lbmpdm_msg_set_field_value_vec (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len[], size_t num_arr_elem) |
Sets an array of field values in a message. More... | |
LBMPDMExpDLL int | lbmpdm_msg_remove_field_value (lbmpdm_msg_t *message, lbmpdm_field_handle_t handle) |
Removes a field value from a message (marking it unset) More... | |
LBMPDMExpDLL int | lbmpdm_msg_set_incl_defn_flag (lbmpdm_msg_t *message) |
Sets the message include definition flag. More... | |
LBMPDMExpDLL int | lbmpdm_msg_unset_incl_defn_flag (lbmpdm_msg_t *message) |
Unsets the message include definition flag. More... | |
LBMPDMExpDLL int | lbmpdm_field_value_stct_delete (lbmpdm_field_value_t *field_value) |
Deletes the allocated resources inside the field value struct. This does NOT free the actual field value struct passed in (which should be done outside PDM). Also, this does not affect the field value in the message, only this field value struct. More... | |
LBMPDMExpDLL int | lbmpdm_msg_serialize (lbmpdm_msg_t *message, char *buffer) |
Serialize a message to a buffer. The message that is passed in is serialized into the caller's supplied buffer. More... | |
LBMPDMExpDLL int | lbmpdm_msg_deserialize (lbmpdm_msg_t *message, const char *bufptr, uint32_t buflen) |
Deserialize the associated buffer into a newly created message. More... | |
LBMPDMExpDLL char * | lbmpdm_msg_get_data (lbmpdm_msg_t *message) |
Serialize a message to a buffer and return the buffer. The message that is passed in is serialized into a buffer which will be cleaned up when the message is deleted. Use lbmpdm_msg_get_length to get the length of the buffer. More... | |
LBMPDMExpDLL int | lbmpdm_iter_create (lbmpdm_iter_t **iter, lbmpdm_msg_t *message) |
Creates a pdm iterator to iterate through the fields in a message. More... | |
LBMPDMExpDLL int | lbmpdm_iter_create_from_field_handle (lbmpdm_iter_t **iter, lbmpdm_msg_t *message, lbmpdm_field_handle_t field_handle) |
Creates a pdm iterator to iterate through the fields in a message starting at a particular field. More... | |
LBMPDMExpDLL int | lbmpdm_iter_delete (lbmpdm_iter_t *iter) |
Deletes the iterator. More... | |
LBMPDMExpDLL lbmpdm_field_handle_t | lbmpdm_iter_get_current (lbmpdm_iter_t *iter) |
Gets the current field handle from the iterator. More... | |
LBMPDMExpDLL int | lbmpdm_iter_first (lbmpdm_iter_t *iter) |
Sets the iterator back to the first field. More... | |
LBMPDMExpDLL int | lbmpdm_iter_next (lbmpdm_iter_t *iter) |
Steps the iterator to the next first field. More... | |
LBMPDMExpDLL uint8_t | lbmpdm_iter_has_next (lbmpdm_iter_t *iter) |
Checks to see if the iterator has another field to step to. More... | |
LBMPDMExpDLL uint8_t | lbmpdm_iter_is_current_set (lbmpdm_iter_t *iter) |
Checks to see if the current field is set. More... | |
LBMPDMExpDLL int | lbmpdm_iter_set_msg (lbmpdm_iter_t *iter, lbmpdm_msg_t *message) |
Sets the message used to step through by this iterator. More... | |
LBMPDMExpDLL int | lbmpdm_iter_set_current_field_value (lbmpdm_iter_t *iter, void *value, size_t len) |
Sets the current field value to the value passed in. More... | |
LBMPDMExpDLL int | lbmpdm_iter_set_current_field_value_vec (lbmpdm_iter_t *iter, void *value, size_t len[], size_t num_arr_elem) |
Sets the current field values to the passed array of values. More... | |
LBMPDMExpDLL int | lbmpdm_iter_get_current_field_value (lbmpdm_iter_t *iter, void *value, size_t *len) |
Gets a field value from the iterator's current field. More... | |
LBMPDMExpDLL int | lbmpdm_iter_get_current_field_value_vec (lbmpdm_iter_t *iter, void *value, size_t len[], size_t *num_arr_elem) |
Gets an array of field values from the iterator's current field. More... | |
Ultra Messaging (UM) Pre-Defined Message (PDM) API. The "lbmpdm.h" header file defines the APIs to create and parse Pre-Defined Messages (PDM). The binary code is contained in the "lbm" library (dynamic on Unix: "liblbm.so", static on Unix: "liblbm.a", dynamic only on Windows: "lbm.dll"). There are also Java and .NET APIs. See Pre-Defined Messages for general information on PDM. See UM C API for general information on the C API. See Fundamental Concepts for an introduction to Ultra Messaging.
#define PDM_DEFN_INT_FIELD_NAMES 1 |
PDM Field Name Type. Use integer field names.
#define PDM_DEFN_STR_FIELD_NAMES 0 |
PDM Field Name Type. Use string field names.
#define PDM_ERR_CREATE_BUFFER 11 |
PDM Error Code. Error creating buffer.
#define PDM_ERR_CREATE_SECTION 10 |
PDM Error Code. Error creating field section.
#define PDM_ERR_DEFN_INVALID 7 |
PDM Error Code. Not a valid PDM definition.
#define PDM_ERR_EINVAL 4 |
PDM Error Code. Invalid parameter given.
#define PDM_ERR_FIELD_IS_NULL 1 |
PDM Error Code. Field is null.
#define PDM_ERR_FIELD_NOT_FOUND 5 |
PDM Error Code. Field not found.
#define PDM_ERR_INSUFFICIENT_BUFFER_LENGTH 3 |
PDM Error Code. Insufficient buffer length given.
#define PDM_ERR_MSG_INVALID 6 |
PDM Error Code. Not a valid PDM message.
#define PDM_ERR_NO_MORE_FIELDS 2 |
PDM Error Code. No more fields to iterate over.
#define PDM_ERR_NOMEM 8 |
PDM Error Code. No memory available.
#define PDM_ERR_REQ_FIELD_NOT_SET 9 |
PDM Error Code. Required field not set.
#define PDM_FAILURE -1 |
PDM Return Code. Operation failed. See lbmpdm_errnum() or lbmpdm_errmsg() for the reason.
#define PDM_FALSE (uint8_t) 0 |
PDM true/false values. PDM value for FALSE.
#define PDM_FIELD_INFO_FLAG_FIXED_STR_LEN 0x2 |
PDM Field Info Flags. Field has a fixed string length (for string and unicode types).
#define PDM_FIELD_INFO_FLAG_NUM_ARR_ELEM 0x4 |
PDM Field Info Flags. Field has a fixed array size (for array types).
#define PDM_FIELD_INFO_FLAG_REQ 0x1 |
PDM Field Info Flags. Field is required.
#define PDM_INTERNAL_TYPE_INVALID -1 |
PDM Field Type. Invalid Type.
#define PDM_ITER_INVALID_FIELD_HANDLE -1 |
PDM Iterator Invalid Handle. Indicates invalid field handle.
#define PDM_MSG_FLAG_DEL_DEFN_WHEN_REPLACED 0x20 |
PDM Message Flags. If a message's existing definition should be deleted when replaced when deserializing a message.
#define PDM_MSG_FLAG_INCL_DEFN 0x2 |
PDM Message Flags. If the definition should be serialized with the message.
#define PDM_MSG_FLAG_NEED_BYTE_SWAP 0x10 |
PDM Message Flags. If the field values need bytes to be swapped (set internally).
#define PDM_MSG_FLAG_TRY_LOAD_DEFN_FROM_CACHE 0x8 |
PDM Message Flags. If a message should try to load a needed definition from the cache when deserializing.
#define PDM_MSG_FLAG_USE_MSG_DEFN_IF_NEEDED 0x4 |
PDM Message Flags. If a message should override its existing definition with one included when deserializing a message.
#define PDM_MSG_FLAG_VAR_OR_OPT_FLDS_SET 0x1 |
PDM Message Flags. If any variable or optional fields have been set (set internally).
#define PDM_MSG_VER_POLICY_BEST 1 |
PDM Message Version Policy. Use Best Match versioning Policy.
#define PDM_MSG_VER_POLICY_EXACT 0 |
PDM Message Version Policy. Use Exact Match versioning Policy.
#define PDM_SUCCESS 0 |
PDM Return Code. Operation was successful.
#define PDM_TRUE (uint8_t) 1 |
PDM true/false values. PDM value for TRUE.
#define PDM_TYPE_BLOB 17 |
PDM Field Type. blob (variable length).
#define PDM_TYPE_BLOB_ARR 36 |
PDM Field Type. blob array.
#define PDM_TYPE_BOOLEAN 0 |
PDM Field Type. boolean.
#define PDM_TYPE_BOOLEAN_ARR 19 |
PDM Field Type. boolean array.
#define PDM_TYPE_DECIMAL 11 |
PDM Field Type. decimal.
#define PDM_TYPE_DECIMAL_ARR 30 |
PDM Field Type. decimal array.
#define PDM_TYPE_DOUBLE 10 |
PDM Field Type. double.
#define PDM_TYPE_DOUBLE_ARR 29 |
PDM Field Type. double array.
#define PDM_TYPE_FIX_STRING 13 |
PDM Field Type. fixed string.
#define PDM_TYPE_FIX_STRING_ARR 32 |
PDM Field Type. fixed string array.
#define PDM_TYPE_FIX_UNICODE 15 |
PDM Field Type. fixed unicode.
#define PDM_TYPE_FIX_UNICODE_ARR 34 |
PDM Field Type. fixed unicode array.
#define PDM_TYPE_FLOAT 9 |
PDM Field Type. float.
#define PDM_TYPE_FLOAT_ARR 28 |
PDM Field Type. float array.
#define PDM_TYPE_INT16 3 |
PDM Field Type. 16 bit integer.
#define PDM_TYPE_INT16_ARR 22 |
PDM Field Type. 16 bit integer array.
#define PDM_TYPE_INT32 5 |
PDM Field Type. 32 bit integer.
#define PDM_TYPE_INT32_ARR 24 |
PDM Field Type. 32 bit integer array.
#define PDM_TYPE_INT64 7 |
PDM Field Type. 64 bit integer.
#define PDM_TYPE_INT64_ARR 26 |
PDM Field Type. 64 bit integer array.
#define PDM_TYPE_INT8 1 |
PDM Field Type. 8 bit integer.
#define PDM_TYPE_INT8_ARR 20 |
PDM Field Type. 8 bit integer array.
#define PDM_TYPE_MESSAGE 18 |
PDM Field Type. PDM message (variable length).
#define PDM_TYPE_MESSAGE_ARR 37 |
PDM Field Type. PDM message array.
#define PDM_TYPE_STRING 14 |
PDM Field Type. string (variable length).
#define PDM_TYPE_STRING_ARR 33 |
PDM Field Type. string array.
#define PDM_TYPE_TIMESTAMP 12 |
PDM Field Type. timestamp.
#define PDM_TYPE_TIMESTAMP_ARR 31 |
PDM Field Type. timestamp array.
#define PDM_TYPE_UINT16 4 |
PDM Field Type. unsigned 16 bit integer.
#define PDM_TYPE_UINT16_ARR 23 |
PDM Field Type. unsigned 16 bit integer array.
#define PDM_TYPE_UINT32 6 |
PDM Field Type. unsigned 32 bit integer.
#define PDM_TYPE_UINT32_ARR 25 |
PDM Field Type. unsigned 32 bit integer array.
#define PDM_TYPE_UINT64 8 |
PDM Field Type. unsigned 64 bit integer.
#define PDM_TYPE_UINT64_ARR 27 |
PDM Field Type. unsigned 64 bit integer array.
#define PDM_TYPE_UINT8 2 |
PDM Field Type. unsigned 8 bit integer.
#define PDM_TYPE_UINT8_ARR 21 |
PDM Field Type. unsigned 8 bit integer array.
#define PDM_TYPE_UNICODE 16 |
PDM Field Type. unicode (variable length).
#define PDM_TYPE_UNICODE_ARR 35 |
PDM Field Type. unicode array.
LBMPDMExpDLL int lbmpdm_cache_init | ( | uint32_t | cache_size | ) |
initialize the cache for a given number of buckets. If 0 is given the the cache will default. The default can be altered via a PDM attribute.
cache_size | – how many buckets should this hash contain? If set to zero this will default. |
LBMPDMExpDLL int lbmpdm_cache_struct_add | ( | lbmpdm_defn_t * | defn | ) |
add a definition structure to the cache. It is assumed that the structure has a unique id, if the id is set to zero the structure will not be inserted into the map.
defn | – the new definition structure being added. |
LBMPDMExpDLL int lbmpdm_cache_struct_find | ( | lbmpdm_defn_t ** | defn, |
int32_t | id | ||
) |
find a given definition structure by id and return the structure for it. Returns PDM_FAILURE for nothing found, and PDM_SUCCESS for something found. Note, since a structure with the id of 0 won't exist in the cache you will never find one being returned from this find with an id of 0.
defn | – pointer to the structure to return. This field is not altered if nothing is found for a given id. |
id | – id to search for in the hash. |
LBMPDMExpDLL int lbmpdm_cache_struct_find_by_version | ( | lbmpdm_defn_t ** | defn, |
int32_t | id, | ||
uint8_t | vers_major, | ||
uint8_t | vers_minor | ||
) |
find a given definition structure by id, major version, and minor version and return the structure for it. Returns PDM_FAILURE for nothing found, and PDM_SUCCESS for something found. Note, since a structure with the id of 0 won't exist in the cache you will never find one being returned from this find with an id of 0.
defn | – pointer to the structure to return. This field is not altered if nothing is found for a given id. |
id | – id to search for in the hash. |
vers_major | – major version to search for in the hash. |
vers_minor | – minor version to search for in the hash. |
LBMPDMExpDLL int lbmpdm_cache_struct_remove | ( | int32_t | id | ) |
delete a definition structure from the cache. Does not error if the structure doesn't exist.
id | – id of the structure being deleted. If the id is not found this will do nothing. |
LBMPDMExpDLL int lbmpdm_cache_struct_remove_by_version | ( | int32_t | id, |
uint8_t | vers_major, | ||
uint8_t | vers_minor | ||
) |
delete a definition structure from the cache by its id and version. Does not error if the structure doesn't exist.
id | – id of the structure being deleted. If the id is not found this will do nothing. |
vers_major | – major version of the definition |
vers_minor | – minor version of the definition |
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_add_field_info_by_int_name | ( | lbmpdm_defn_t * | defn, |
int32_t | int_name, | ||
int16_t | type, | ||
lbmpdm_field_info_attr_t * | info_attr | ||
) |
adds field info to the definition by integer name
defn | – A pointer to a PDM defn object. |
int_name | – the integer name |
type | – the PDM field type |
info_attr | – the field information attributes |
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_add_field_info_by_str_name | ( | lbmpdm_defn_t * | defn, |
const char * | str_name, | ||
int16_t | type, | ||
lbmpdm_field_info_attr_t * | info_attr | ||
) |
adds field info to the definition by string name
defn | – A pointer to a PDM defn object. |
str_name | – the string name |
type | – the PDM field type |
info_attr | – the field information attributes |
LBMPDMExpDLL int lbmpdm_defn_create | ( | lbmpdm_defn_t ** | defn, |
int32_t | num_fields, | ||
int32_t | id, | ||
int8_t | vrs_mjr, | ||
int8_t | vrs_mnr, | ||
uint8_t | field_names_type | ||
) |
Create a definition, with the passed number of fields. The num_fields is required to be at least 1. The number of fields can grow beyond this value, it is used initially to size the internal field info array.
defn | – pointer to newly created definition. |
num_fields | – how many fields to initially assume we will have, this is for optimization, not a limit to how many fields. |
id | – This is the id for the definition. It is assumed that this is a unique id. |
vrs_mjr | – A version major number to be assigned to the newly created definition. When deserializing a message, PDM will attempt to use the existing set definition if the ids match. If the message flag is set to use the included message definition or try to load the definition from the cache, then an attempt will be made to replace the set definition with the new one by its version numbers. Please note: when versioning message definitions, adding optional fields only is the safest way to unsure interoperability with older versions. Adding new required fields or modifying the types of existing required fields may lead to messages that are not deserializable by receivers with older definition versions. |
vrs_mnr | – A version minor number |
field_names_type | – A type that indicates whether the field names will be strings or ints. Use either PDM_DEFN_STR_FIELD_NAMES or PDM_DEFN_INT_FIELD_NAMES for the value. |
LBMPDMExpDLL int lbmpdm_defn_delete | ( | lbmpdm_defn_t * | defn | ) |
delete a given definition.
defn | – definition to be deleted. |
LBMPDMExpDLL int lbmpdm_defn_deserialize | ( | lbmpdm_defn_t * | defn, |
const char * | bufptr, | ||
uint32_t | buflen, | ||
uint8_t | swap_bytes | ||
) |
Deserialize the associated buffer into a newly created defn.
This will take the passed buffer and deserialize the contents into a newly created defn. When finished with the defn, the caller must call lbmpdm_defn_delete() to properly dispose of the defn. This is done automatically by a message when the defn is included. The message normally indicates to the definition whether or not swap bytes need to be set to PDM_TRUE so to use this method directly, this knowledge must be determined outside PDM.
defn | A pointer to a previously created PDM defn object |
bufptr | The buffer to be deserialized |
buflen | The length of the buffer. |
swap_bytes | Whether or not bytes should be swapped to deal with endianness. |
LBMPDMExpDLL int lbmpdm_defn_finalize | ( | lbmpdm_defn_t * | defn | ) |
make this definition final. This needs to be done before using it in a message.
defn | – the definition to be finalized. |
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_get_field_handle_by_int_name | ( | lbmpdm_defn_t * | defn, |
int32_t | int_name | ||
) |
Retrieve a field handle from a definition via name.
defn | – definition created from lbmpdm_defn_create. |
int_name | – the name of the field to be retrieved. |
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_get_field_handle_by_str_name | ( | lbmpdm_defn_t * | defn, |
const char * | str_name | ||
) |
Retrieve a field handle from a definition via name.
defn | – definition created from lbmpdm_defn_create. |
str_name | – the name of the field to be retrieved. |
LBMPDMExpDLL int32_t lbmpdm_defn_get_field_info_int_name | ( | lbmpdm_defn_t * | defn, |
lbmpdm_field_handle_t | handle | ||
) |
Gets the integer field name from a given definition's field handle.
defn | – A pointer to a PDM defn object. |
handle | – A valid field handle from the definition. |
LBMPDMExpDLL const char* lbmpdm_defn_get_field_info_str_name | ( | lbmpdm_defn_t * | defn, |
lbmpdm_field_handle_t | handle | ||
) |
Gets the string field name from a given definition's field handle.
defn | – A pointer to a PDM defn object. |
handle | – A valid field handle from the definition. |
LBMPDMExpDLL int16_t lbmpdm_defn_get_field_info_type | ( | lbmpdm_defn_t * | defn, |
lbmpdm_field_handle_t | handle | ||
) |
Gets the PDM field type from a given definition's field handle.
defn | – A pointer to a PDM defn object. |
handle | – A valid field handle from the definition. |
LBMPDMExpDLL uint8_t lbmpdm_defn_get_field_names_type | ( | lbmpdm_defn_t * | defn | ) |
Gets the field names type (either PDM_DEFN_STR_FIELD_NAMES or PDM_DEFN_INT_FIELD_NAMES) from the definition.
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL int32_t lbmpdm_defn_get_id | ( | lbmpdm_defn_t * | defn | ) |
Gets the id of the definition.
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL uint32_t lbmpdm_defn_get_length | ( | lbmpdm_defn_t * | defn | ) |
Gets the exact length of the serialized defn. This can be used to allocate a buffer of the exact length needed to serialize the defn.
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL int8_t lbmpdm_defn_get_msg_vers_major | ( | lbmpdm_defn_t * | defn | ) |
Gets the message major version number from the definition.
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL int8_t lbmpdm_defn_get_msg_vers_minor | ( | lbmpdm_defn_t * | defn | ) |
Gets the message minor version number from the definition.
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL int32_t lbmpdm_defn_get_num_fields | ( | lbmpdm_defn_t * | defn | ) |
Gets the number of fields in the definition.
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL uint8_t lbmpdm_defn_is_finalized | ( | lbmpdm_defn_t * | defn | ) |
Gets whether or not the definition has been finalized (either PDM_TRUE or PDM_FALSE).
defn | – A pointer to a PDM defn object. |
LBMPDMExpDLL int lbmpdm_defn_serialize | ( | lbmpdm_defn_t * | defn, |
char * | buffer, | ||
uint32_t * | defn_len | ||
) |
Serialize a defn to a buffer. In normal usage this is not needed as the defn is either known in advance or sent as part of a message. The defn that is passed in is serialized into the caller's supplied buffer.
defn | A PDM defn to be serialized |
buffer | The caller allocated buffer |
defn_len | Will be set to the length of the definition |
LBMPDMExpDLL const char* lbmpdm_errmsg | ( | ) |
Return an ASCII string containing the error message last encountered by this thread.
LBMPDMExpDLL int lbmpdm_errnum | ( | ) |
Return the error number last encountered by this thread.
LBMPDMExpDLL int lbmpdm_field_value_stct_delete | ( | lbmpdm_field_value_t * | field_value | ) |
Deletes the allocated resources inside the field value struct. This does NOT free the actual field value struct passed in (which should be done outside PDM). Also, this does not affect the field value in the message, only this field value struct.
field_value | – A pointer to a field value structure. |
LBMPDMExpDLL int lbmpdm_iter_create | ( | lbmpdm_iter_t ** | iter, |
lbmpdm_msg_t * | message | ||
) |
Creates a pdm iterator to iterate through the fields in a message.
iter | – Pointer to the iterator pointer which will be created |
message | – the pdm message |
LBMPDMExpDLL int lbmpdm_iter_create_from_field_handle | ( | lbmpdm_iter_t ** | iter, |
lbmpdm_msg_t * | message, | ||
lbmpdm_field_handle_t | field_handle | ||
) |
Creates a pdm iterator to iterate through the fields in a message starting at a particular field.
iter | – Pointer to the iterator pointer which will be created |
message | – the pdm message |
field_handle | – the handle to the field where the iterator should start |
LBMPDMExpDLL int lbmpdm_iter_delete | ( | lbmpdm_iter_t * | iter | ) |
Deletes the iterator.
iter | – the pdm iterator |
LBMPDMExpDLL int lbmpdm_iter_first | ( | lbmpdm_iter_t * | iter | ) |
Sets the iterator back to the first field.
iter | – the pdm iterator |
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_iter_get_current | ( | lbmpdm_iter_t * | iter | ) |
Gets the current field handle from the iterator.
iter | – The pdm iterator |
LBMPDMExpDLL int lbmpdm_iter_get_current_field_value | ( | lbmpdm_iter_t * | iter, |
void * | value, | ||
size_t * | len | ||
) |
Gets a field value from the iterator's current field.
iter | – the pdm iterator |
value | – A pointer to a value big enough to hold the field value |
len | – A pointer describing the currently allocated length of the void *value. If it is not large enough to hold the field value, PDM_FAILURE will be returned and len will be set to the needed length. |
LBMPDMExpDLL int lbmpdm_iter_get_current_field_value_vec | ( | lbmpdm_iter_t * | iter, |
void * | value, | ||
size_t | len[], | ||
size_t * | num_arr_elem | ||
) |
Gets an array of field values from the iterator's current field.
iter | – the pdm iterator |
value | – A pointer to an array of values big enough to hold the field values |
len | – An array of lengths describing the currently allocated length of each void *value array element. If it is not large enough to hold the field value, PDM_FAILURE will be returned and that len element will be set to the needed length. |
num_arr_elem | – The number of elements in the value and len array. |
LBMPDMExpDLL uint8_t lbmpdm_iter_has_next | ( | lbmpdm_iter_t * | iter | ) |
Checks to see if the iterator has another field to step to.
iter | – the pdm iterator |
LBMPDMExpDLL uint8_t lbmpdm_iter_is_current_set | ( | lbmpdm_iter_t * | iter | ) |
Checks to see if the current field is set.
iter | – the pdm iterator |
LBMPDMExpDLL int lbmpdm_iter_next | ( | lbmpdm_iter_t * | iter | ) |
Steps the iterator to the next first field.
iter | – the pdm iterator |
LBMPDMExpDLL int lbmpdm_iter_set_current_field_value | ( | lbmpdm_iter_t * | iter, |
void * | value, | ||
size_t | len | ||
) |
Sets the current field value to the value passed in.
iter | – the pdm iterator |
value | – the new field value |
len | – the len of the enw field value |
LBMPDMExpDLL int lbmpdm_iter_set_current_field_value_vec | ( | lbmpdm_iter_t * | iter, |
void * | value, | ||
size_t | len[], | ||
size_t | num_arr_elem | ||
) |
Sets the current field values to the passed array of values.
iter | – the pdm iterator |
value | – A pointer to an array of values that should be set into the message |
len | – A size_t array describing the currently allocated lengths of each element in the value array For fixed length types, setting a len element to 0 will allow it to default to the fixed length size of the type. |
num_arr_elem | – The number of elements in the value and len array. |
LBMPDMExpDLL int lbmpdm_iter_set_msg | ( | lbmpdm_iter_t * | iter, |
lbmpdm_msg_t * | message | ||
) |
Sets the message used to step through by this iterator.
iter | – the pdm iterator |
message | – the pdm message to step through |
LBMPDMExpDLL int lbmpdm_msg_and_defn_delete | ( | lbmpdm_msg_t * | message | ) |
Delete an lbmpdm_msg_t object and all associated resources (including the defn) This deletes a previously created PDM message and all resources associated with the message.
message | – A pointer to a PDM message object. |
LBMPDMExpDLL int lbmpdm_msg_create | ( | lbmpdm_msg_t ** | message, |
lbmpdm_defn_t * | defn, | ||
uint32_t | flags | ||
) |
creates a message with the specified definition
message | – pointer to the newly created message |
defn | – the definition to be used by the message |
flags | – flags to set in the message |
LBMPDMExpDLL int lbmpdm_msg_delete | ( | lbmpdm_msg_t * | message | ) |
Delete an lbmpdm_msg_t object and all associated resources (except the defn) This deletes a previously created PDM message and all resources associated with the message.
message | – A pointer to a PDM message object. |
LBMPDMExpDLL int lbmpdm_msg_deserialize | ( | lbmpdm_msg_t * | message, |
const char * | bufptr, | ||
uint32_t | buflen | ||
) |
Deserialize the associated buffer into a newly created message.
This will take the passed buffer and deserialize the contents into a newly created message. It will verify that the buffer is a valid PDM message before trying to deserialize. When finished with the message, the caller must call lbmpdm_msg_delete() to properly dispose of the message.
message | A pointer to a previously created PDM message object |
bufptr | The buffer to be deserialized |
buflen | The length of the buffer. |
LBMPDMExpDLL char* lbmpdm_msg_get_data | ( | lbmpdm_msg_t * | message | ) |
Serialize a message to a buffer and return the buffer. The message that is passed in is serialized into a buffer which will be cleaned up when the message is deleted. Use lbmpdm_msg_get_length to get the length of the buffer.
message | A PDM Message to be serialized |
LBMPDMExpDLL lbmpdm_defn_t* lbmpdm_msg_get_defn | ( | const lbmpdm_msg_t * | message | ) |
Gets a pointer to the message definition.
message | – A pointer to a PDM message object. |
LBMPDMExpDLL int lbmpdm_msg_get_field_value | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle, | ||
void * | value, | ||
size_t * | len | ||
) |
Gets a field value from the message.
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
value | – A pointer to a value big enough to hold the field value |
len | – A pointer describing the currently allocated length of the void *value. If it is not large enough to hold the field value, PDM_FAILURE will be returned and len will be set to the needed length. |
LBMPDMExpDLL int lbmpdm_msg_get_field_value_stct | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle, | ||
lbmpdm_field_value_t * | field_value | ||
) |
Populates a field value struct with the value from the message.
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
field_value | – A pointer to a field value structure |
LBMPDMExpDLL int lbmpdm_msg_get_field_value_vec | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle, | ||
void * | value, | ||
size_t | len[], | ||
size_t * | num_arr_elem | ||
) |
Gets an array of field values from the message.
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
value | – An array of pointers with each one already allocated of sufficient length to hold each field value element |
len | – An array describing the currently allocated lengths of each element of the void *value. If any len element is not large enough to hold the field value, PDM_FAILURE will be returned and the len array will be set to the needed lengths. |
num_arr_elem | – A pointer to the number of allocated elements in the value and len arrays. If the number is less than the number of elements in the actual field value, PDM_FAILURE will be returned and num_arr_elem will be set to the correct value. |
LBMPDMExpDLL uint32_t lbmpdm_msg_get_length | ( | const lbmpdm_msg_t * | message | ) |
Gets the exact length of the serialized message. This can be used to allocate a buffer of the exact length needed to serialize the message.
message | – A pointer to a PDM message object. |
LBMPDMExpDLL uint8_t lbmpdm_msg_is_field_set | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle | ||
) |
Gets whether or not the field value has been set.
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
LBMPDMExpDLL int lbmpdm_msg_remove_field_value | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle | ||
) |
Removes a field value from a message (marking it unset)
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
LBMPDMExpDLL int lbmpdm_msg_serialize | ( | lbmpdm_msg_t * | message, |
char * | buffer | ||
) |
Serialize a message to a buffer. The message that is passed in is serialized into the caller's supplied buffer.
message | A PDM Message to be serialized |
buffer | The caller allocated buffer |
LBMPDMExpDLL int lbmpdm_msg_set_field_value | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle, | ||
void * | value, | ||
size_t | len | ||
) |
Sets a field value in a message.
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
value | – A pointer to a value that should be set into the message |
len | – A size_t describing the currently allocated length of the void *value. For fixed length types, setting len to 0 will allow it to default to the fixed length size of the type. |
LBMPDMExpDLL int lbmpdm_msg_set_field_value_vec | ( | lbmpdm_msg_t * | message, |
lbmpdm_field_handle_t | handle, | ||
void * | value, | ||
size_t | len[], | ||
size_t | num_arr_elem | ||
) |
Sets an array of field values in a message.
message | – A pointer to a PDM message object. |
handle | – A valid field handle |
value | – A pointer to an array of values that should be set into the message |
len | – A size_t array describing the currently allocated lengths of each element in the value array For fixed length types, setting a len element to 0 will allow it to default to the fixed length size of the type. |
num_arr_elem | – The number of elements in the value and len array. |
LBMPDMExpDLL int lbmpdm_msg_set_incl_defn_flag | ( | lbmpdm_msg_t * | message | ) |
Sets the message include definition flag.
message | – A pointer to a PDM message object. |
LBMPDMExpDLL int lbmpdm_msg_unset_incl_defn_flag | ( | lbmpdm_msg_t * | message | ) |
Unsets the message include definition flag.
message | – A pointer to a PDM message object. |