MessageHelper Class Reference

#include <MessageHelper.h>

Inheritance diagram for MessageHelper:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 MessageHelper ()
virtual ~MessageHelper ()
void SetBuffer (void *const buffer)
void * GetBuffer (void) const
void * GetCurrentPosition (void) const
virtual void AddVariable (const void *variable, const int size)
virtual void AddData (const void *data, const int size)
void GetVariable (void *const variable, const int size)
void GetData (void *const data, const int size)
int GetSize (void) const
void SetSize (const int size)
void AddInteger (const int value)
void AddFloat (const float value)
int GetInteger (void)
float GetFloat (void)
std::string DumpAsHex (const bool csv=true)
void SetGuardSize (const int size=-1)

Static Public Member Functions

static std::string DumpAsHex (const void *data, const int size, const bool csv=true)

Classes

class  Exception


Detailed Description

A simple message helper class that helps to construct and deconstruct sequences of variables. This routine is endian safe and should be used where data needs to be endian safe

Constructor & Destructor Documentation

MessageHelper (  ) 

The ctor performs some basic initialisation

virtual ~MessageHelper (  )  [virtual]

The dtor makes sure everything is tidy


Member Function Documentation

void SetBuffer ( void *const   buffer  ) 

Sets the data buffer pointer to use while constructing or deconstructing this message. This also causes the length of the buffer to revert to zero.

Parameters:
buffer the buffer pointer to set

void* GetBuffer ( void   )  const

Gets the pointer to the start of the buffer.

Returns:
The pointer to the start of the buffer.

void* GetCurrentPosition ( void   )  const

Gets the pointer to the current position in the buffer.

Returns:
The pointer to the current position in the buffer.

virtual 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 in DynamicMessageHelper.

virtual 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 in DynamicMessageHelper.

void GetVariable ( void *const   variable,
const int  size 
)

Gets a variable of a specified size from the message buffer

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

void GetData ( void *const   data,
const int  size 
)

Gets data of a specified size from the message buffer

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

int GetSize ( void   )  const

Returns the current size of the message in bytes

Returns:
returns the size of the message buffer in bytes

void SetSize ( const int  size  ) 

Sets the current size of the message in bytes.

Parameters:
the size of the message in bytes

Reimplemented in DynamicMessageHelper.

void AddInteger ( const int  value  ) 

Adds an integer to the message buffer

Parameters:
value the value to add

void AddFloat ( const float  value  ) 

Adds a float to the message buffer

Parameters:
value the value to add

int GetInteger ( void   ) 

Gets an integer from the message buffer

Parameters:
value the value to get

float GetFloat ( void   ) 

Gets a float from the message buffer

Parameters:
value the value to get

static std::string DumpAsHex ( const void *  data,
const int  size,
const bool  csv = true 
) [static]

This produces a hex dump of any length of data

void SetGuardSize ( const int  size = -1  ) 

Sets the guard size and if the MessageHepler reads past the guard a MessageHepler::Exception() exception is thrown.

Parameters:
size If < 0 then the exception is disabled. Otherwise an exception is thrown when data is read beyond the size configured.


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