In-memory storage of an encoded weather report. More...
#include <dballe/core/error.h>
Go to the source code of this file.
Data Structures | |
struct | _dba_rawmsg |
Dynamic storage for encoded messages. More... | |
Typedefs | |
typedef struct _dba_rawmsg * | dba_rawmsg |
Enumerations | |
enum | dba_encoding { BUFR = 0, CREX = 1, AOF = 2 } |
Supported encodings for report data. | |
Functions | |
const char * | dba_encoding_name (dba_encoding enc) |
Return a string with the name of the given encoding. | |
dba_err | dba_rawmsg_create (dba_rawmsg *msg) |
Create a new dba_rawmsg. | |
void | dba_rawmsg_delete (dba_rawmsg msg) |
Delete a dba_rawmsg. | |
void | dba_rawmsg_reset (dba_rawmsg msg) |
Clear all the contents of this dba_rawmsg. | |
dba_err | dba_rawmsg_acquire_buf (dba_rawmsg msg, unsigned char *buf, int size) |
Set the internal buffer to `buf', taking ownership of the buffer. | |
dba_err | dba_rawmsg_get_raw (dba_rawmsg msg, const unsigned char **buf, int *size) |
Get the raw (encoded) representation of the message. | |
dba_err | dba_rawmsg_expand_buffer (dba_rawmsg msg) |
Expand the size of the buffer holding message data. | |
dba_err | dba_rawmsg_copy (dba_rawmsg *dst, dba_rawmsg src) |
Make a copy of a message. |
In-memory storage of an encoded weather report.
typedef struct _dba_rawmsg* dba_rawmsg |
Dynamic storage for encoded messages.
const char* dba_encoding_name | ( | dba_encoding | enc ) |
Return a string with the name of the given encoding.
enc | The encoding to name. |
dba_err dba_rawmsg_copy | ( | dba_rawmsg * | dst, |
dba_rawmsg | src | ||
) |
Make a copy of a message.
Note: the resulting message will reference the same dba_file as the source message.
dst | Destination message. It will be freshly allocated, and it will need to be deallocated by the caller. |
src | The source message. |
References _dba_rawmsg::alloclen, _dba_rawmsg::buf, DBA_RUN_OR_GOTO, _dba_rawmsg::encoding, _dba_rawmsg::file, _dba_rawmsg::index, _dba_rawmsg::len, and _dba_rawmsg::offset.
dba_err dba_rawmsg_create | ( | dba_rawmsg * | msg ) |
Create a new dba_rawmsg.
msg | The new dba_rawmsg. It will need to be deallocated using dba_rawmsg_delete() |
void dba_rawmsg_delete | ( | dba_rawmsg | msg ) |
Delete a dba_rawmsg.
msg | The dba_rawmsg to delete |
References _dba_rawmsg::alloclen, and _dba_rawmsg::buf.
dba_err dba_rawmsg_expand_buffer | ( | dba_rawmsg | msg ) |
Expand the size of the buffer holding message data.
Allocation is optimised for the normal message size of meteorological data: if the buffer size is below 16Kbytes, then the size is doubled; when above 16Kb, then it is grown by 2Kb.
msg | The message to enlarge |
References _dba_rawmsg::alloclen, and _dba_rawmsg::buf.
dba_err dba_rawmsg_get_raw | ( | dba_rawmsg | msg, |
const unsigned char ** | buf, | ||
int * | size | ||
) |
Get the raw (encoded) representation of the message.
msg | The message to query |
buf | A const pointer to the internal buffer with the encoded representation of the message. |
size | The size of the data in buf |
References _dba_rawmsg::buf, and _dba_rawmsg::len.
void dba_rawmsg_reset | ( | dba_rawmsg | msg ) |
Clear all the contents of this dba_rawmsg.
msg | The dba_rawmsg to clear |
References _dba_rawmsg::index, _dba_rawmsg::len, and _dba_rawmsg::offset.