DynamicMessageHelper Class Reference

#include <MessageHelper.h>

Inheritance diagram for DynamicMessageHelper:

Inheritance graph
[legend]
Collaboration diagram for DynamicMessageHelper:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 DynamicMessageHelper ()
virtual ~DynamicMessageHelper ()
void SetBufferSize (const int size=1024)
int GetBufferSize (void)
void SetSize (const int size)
void AddVariable (const void *variable, const int size)
void AddData (const void *data, const int size)
void FreeBuffer (void)
void EnsureBufferAllocated (void)
bool Write (const char *filename)
bool Read (const char *filename)
template<typename T>
void operator<< (const T &rhs)
template<typename T>
void operator>> (T &rhs)
void operator<< (const char *rhs)
void operator<< (const std::string &rhs)
void operator>> (std::string &rhs)
void operator<< (const DynamicMessageHelper &rhs)
void operator>> (DynamicMessageHelper &rhs)
bool operator== (const DynamicMessageHelper &rhs) const
bool operator!= (const DynamicMessageHelper &rhs) const
bool ReadAsHex (const std::string data)


Detailed Description

This extends the interface provided by MessageHelper to include a data buffer that dynamically grows to accommodate new data.

Constructor & Destructor Documentation

DynamicMessageHelper (  ) 

The ctor performs some basic initialisation

virtual ~DynamicMessageHelper (  )  [virtual]

The dtor makes sure everything is tidy


Member Function Documentation

void SetBufferSize ( const int  size = 1024  ) 

Sets the data buffer size to use while constructing or deconstructing this message. Any previous buffer is freed. The buffer is not allocated immediately, buffer allocation happens when data is added to the buffer. To force an allocation of the buffer use EnsureBufferAllocated().

Parameters:
buffer the buffer pointer to set. The default size is 1024 bytes.

int GetBufferSize ( void   ) 

Gets the value configured by SetBufferSize().

Returns:
The value configured by SetBufferSize().

void SetSize ( const int  size  ) 

Sets the current size of the message in bytes, allocating a buffer if required.

Parameters:
the size of the message in bytes

Reimplemented from MessageHelper.

void AddVariable ( const void *  variable,
const int  size 
) [virtual]

Adds a variable of a specified size to the message buffer while using an endian check to preserve the value between platforms with different endian formats

Parameters:
variable the pointer to the variable
size the size of the data

Reimplemented from MessageHelper.

void AddData ( const void *  data,
const int  size 
) [virtual]

Adds a data block of a specified size to the message buffer without using any endian checking

Parameters:
data the pointer to the data
size the size of the data

Reimplemented from MessageHelper.

void FreeBuffer ( void   ) 

This frees the buffer used by this class and sets the current size to 0. This also calls SetBufferSize() to reset the size to the default value.

void EnsureBufferAllocated ( void   ) 

This ensures the buffer is allocated.

bool Write ( const char *  filename  ) 

Writes the contents of this class to a file.

bool Read ( const char *  filename  ) 

Reads the contents of a file to this class. GetBufferSize() will return the size of the message in the file and GetSize() will return 0.

bool ReadAsHex ( const std::string  data  ) 

Reads a hex encoded buffer without commas and converts it to binary data from the current position of the buffer. If there is an error reading the data then the result of the buffer is undefined.

Returns:
Success returns true, failure returns false.


Generated on Sat Jun 28 22:02:24 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3