libdballe 4.0.18
Data Structures | Typedefs | Enumerations | Functions
rawmsg.h File Reference

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_rawmsgdba_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.

Detailed Description

In-memory storage of an encoded weather report.


Typedef Documentation

typedef struct _dba_rawmsg* dba_rawmsg

Dynamic storage for encoded messages.


Function Documentation

const char* dba_encoding_name ( dba_encoding  enc)

Return a string with the name of the given encoding.

Parameters:
encThe encoding to name.
Returns:
A short name for the encoding, such as "BUFR", "CREX", "AOF" or "(unknown)".
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.

Parameters:
dstDestination message. It will be freshly allocated, and it will need to be deallocated by the caller.
srcThe source message.
Returns:
The error indicator for the function. See error.h

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.

Return values:
msgThe new dba_rawmsg. It will need to be deallocated using dba_rawmsg_delete()
Returns:
The error indicator for the function. See error.h
void dba_rawmsg_delete ( dba_rawmsg  msg)

Delete a dba_rawmsg.

Parameters:
msgThe dba_rawmsg to delete
Returns:
The error indicator for the function. See error.h

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.

Parameters:
msgThe message to enlarge
Returns:
The error indicator for the function. See error.h

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.

Parameters:
msgThe message to query
Return values:
bufA const pointer to the internal buffer with the encoded representation of the message.
sizeThe size of the data in buf
Returns:
The error indicator for the function. See error.h

References _dba_rawmsg::buf, and _dba_rawmsg::len.

void dba_rawmsg_reset ( dba_rawmsg  msg)

Clear all the contents of this dba_rawmsg.

Parameters:
msgThe dba_rawmsg to clear

References _dba_rawmsg::index, _dba_rawmsg::len, and _dba_rawmsg::offset.