kpilot

Pilot::dlp< t > Struct Template Reference

#include <pilot.h>


Detailed Description

template<typename t>
struct Pilot::dlp< t >

blob handling

For reading and writing binary blobs -- which has to happen to pack data into the format that the handheld needs -- it is important to remember that the handheld has only four data types (as far as I can tell: byte, short (a 2 byte integer), long (a 4 byte integer) and string (NUL terminated). The sizes of the types on the handheld do not necessarily correspond to the sizes of the same-named types on the desktop. This means that 'reading a long' from a binary blob must always be 4 bytes -- not sizeof(long).

The following templates help out in manipulating the blobs. Instantiate them with the type name you need (char, short, long or char *) and you get a size enum specifying the number of bytes (where applicable) and append and read methods for appending a value of the given type to a pi_buffer_t or reading one from the buffer, respectively.

The usage of read and append is straightforward:

append(pi_buffer_t *b, TYPE_VALUE v) Appends the type value v to the buffer b , extending the buffer as needed.

TYPE_VALUE read(pi_buffer_t *b, unsigned int &offset) Read a value from the buffer b at position offset and return it. The offset value is increased by the number of bytes read from the buffer.

To write a binary blob, a sequence of append calls constructs the blob. To read the same blob, a sequence of read calls with the same type parameters is sufficient.

The calls may vary a little: the exact interface differs depending on the needs of the type of data to be written to the blob.

Definition at line 267 of file pilot.h.


The documentation for this struct was generated from the following file: