class CAVERNplus_datapack_c

Data packing class

Public Methods

CAVERNplus_datapack_c (char *buff, int sz)
User must specify a pre-allocated data buffer and size of the buffer.
char* getBuffer ()
Retrieve the data buffer.
int getBufferFilledSize ()
Retrieve the size of the data buffer that has been packed with data so far.
int getBufferMaxSize ()
Retrieve the original full size of the data buffer.
int pack (char *buf, int sz)
Raw char*
int packChar (char val)
Char
int packDouble (double val)
Double
int packFloat (float val)
Floats
int packInt (int val)
Int
int packLong (long val)
Long
void restart ()
Reset the packing position to the beginning of the buffer.
void setBuffer (char *buff, int sz)
User can switch data buffers. But again you need to specify the size.
int unpack (char *buf, int sz)
Char*
char unpackChar ()
Char
double unpackDouble ()
Double
float unpackFloat ()
Float
int unpackInt ()
Int
long unpackLong ()
Long

Documentation

Data packing class. It is basically a glorified memcpy(). The idea is that you create an object to help you pack data for transmission over networks.

First you create a CAVERNplus_datapack_c object. Then assign it a pre-allocated memory buffer. Then using the various pack*() member functions, you can pack integers, characters, floats etc into the buffer. When done you can simply assign the buffer to whatever call needs the buffer.

Similarly if you receive a buffer of data from the network, you can unpack its constituent components using the unpack*() member functions. Note: this class does not save the format of your packing or unpacking it simply lays out your data in the buffer you provide it. You must pack things and unpack things in the same order in order for them to make sense.


This class has no child classes.
Author:
: Jason Leigh
Version:
: 3/7/97

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de