The Original CHomP Software
|
This class is used to convert data structures into a single sequence of bytes and to retrieve this data for the purpose of communication between a coordinator and workers. More...
#include <mwdata.h>
Public Member Functions | |
mwData () | |
The default constructor of empty data. More... | |
~mwData () | |
The destructor. More... | |
mwData (const mwData &x) | |
The copy constructor. More... | |
mwData & | operator= (const mwData &x) |
The assignment operator. More... | |
mwData & | Swap (mwData &x) |
Swaps the data with another data structure. More... | |
mwData & | Take (mwData &x) |
Takes the data from another data structure and makes the other data empty. More... | |
mwData & | Take (unsigned char *buffer, int length) |
Takes raw data that was allocated with the "new" operator. More... | |
mwData & | Take (char *buffer, int length) |
Takes raw data that was allocated with the "new" operator. More... | |
const char * | Buffer () const |
Returns a pointer to the data buffer. More... | |
int | Length () const |
Returns the length of all the data in the buffer. More... | |
mwData & | Rewind () |
Rewinds the buffer to the beginning for reading. More... | |
mwData & | Reset () |
Forgets the buffer and makes the data empty. More... | |
int | Position (int newpos) |
Sets the current reading position in the buffer. More... | |
int | Position () const |
Returns the current reading position in the buffer. More... | |
mwData & | Append (const char *buffer, int length) |
Appends raw data to the buffer. More... | |
mwData & | Append (const unsigned char *buffer, int length) |
Appends raw data to the buffer. More... | |
mwData & | Append (const mwData &x) |
Appends the entire data buffer to the data. More... | |
const char * | Current () const |
Returns the currently pointed data in the buffer. More... | |
mwData & | Append (const int &x) |
mwData & | Retrieve (int &x) |
mwData & | Append (const unsigned int &x) |
mwData & | Retrieve (unsigned int &x) |
mwData & | Append (const short &x) |
mwData & | Retrieve (short &x) |
mwData & | Append (const unsigned short &x) |
mwData & | Retrieve (unsigned short &x) |
mwData & | Append (const long &x) |
mwData & | Retrieve (long &x) |
mwData & | Append (const unsigned long &x) |
mwData & | Retrieve (unsigned long &x) |
mwData & | Append (const char &x) |
mwData & | Retrieve (char &x) |
mwData & | Append (const unsigned char &x) |
mwData & | Retrieve (unsigned char &x) |
mwData & | Append (const float &x) |
mwData & | Retrieve (float &x) |
mwData & | Append (const double &x) |
mwData & | Retrieve (double &x) |
mwData & | Append (const char *x) |
mwData & | Retrieve (char *x) |
mwData & | Append (const unsigned char *x) |
mwData & | Retrieve (unsigned char *x) |
mwData & | SkipString () |
Skips a zero-terminated string in the buffer. More... | |
Private Member Functions | |
void | IncreaseBuffer (int n) |
Increases the buffer by the given number of bytes (or more) beyond the current position. More... | |
mwData & | AppendBytes (const unsigned char *x, int n) |
Appends a data piece to the buffer and swaps bytes if necessary. More... | |
mwData & | RetrieveBytes (unsigned char *x, int n) |
Retrieve a data piece from the buffer and swaps bytes if necessary. More... | |
Private Attributes | |
unsigned char * | buf |
The data buffer. More... | |
int | len |
The length of the data in the buffer and the write position. More... | |
int | allocated |
The length of the allocated buffer memory space. More... | |
int | pos |
The current read position in the buffer. More... | |
This class is used to convert data structures into a single sequence of bytes and to retrieve this data for the purpose of communication between a coordinator and workers.
It is assumed that 'int' has at least 32 bits and 'double' has 64 bits. For 'bool', 'long long' and 'string', see the corresponding constants. In the buffer: 'char' = 8-bit, 'short' = 16-bit, 'int' = 32-bit, 'long' and 'long long' = 64-bit, 'float' = 32-bit, 'double' = 64-bit (all big endian). NOTE: Until January 21, 2010 'long' was supposed to be 32 bits long.
|
inline |
The default constructor of empty data.
Definition at line 195 of file mwdata.h.
|
inline |
|
inline |
|
inline |
Definition at line 686 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Appends raw data to the buffer.
Definition at line 401 of file mwdata.h.
References Append().
Referenced by Append().
|
inline |
|
inline |
Definition at line 748 of file mwdata.h.
References AppendBytes(), and IncreaseBuffer().
|
inline |
Definition at line 735 of file mwdata.h.
References AppendBytes(), and IncreaseBuffer().
|
inline |
Definition at line 465 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Definition at line 541 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
Appends the entire data buffer to the data.
Definition at line 429 of file mwdata.h.
|
inline |
Definition at line 507 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Definition at line 701 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Appends raw data to the buffer.
Definition at line 393 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Definition at line 787 of file mwdata.h.
References Append(), and IncreaseBuffer().
|
inline |
Definition at line 486 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Definition at line 583 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inline |
Definition at line 524 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
|
inlineprivate |
Appends a data piece to the buffer and swaps bytes if necessary.
Definition at line 348 of file mwdata.h.
References buf, IncreaseBuffer(), and len.
Referenced by Append().
|
inline |
|
inline |
|
inlineprivate |
Increases the buffer by the given number of bytes (or more) beyond the current position.
Definition at line 325 of file mwdata.h.
References allocated, buf, and len.
Referenced by Append(), and AppendBytes().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 754 of file mwdata.h.
References len, pos, and RetrieveBytes().
|
inline |
Definition at line 741 of file mwdata.h.
References len, pos, and RetrieveBytes().
|
inline |
Definition at line 475 of file mwdata.h.
Referenced by Retrieve().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
Retrieve a data piece from the buffer and swaps bytes if necessary.
Definition at line 370 of file mwdata.h.
Referenced by Retrieve().
|
inline |
|
inline |
Swaps the data with another data structure.
Definition at line 244 of file mwdata.h.
|
inline |
Takes raw data that was allocated with the "new" operator.
Definition at line 303 of file mwdata.h.
References Take().
Takes the data from another data structure and makes the other data empty.
Definition at line 273 of file mwdata.h.
References allocated, buf, len, and pos.
Referenced by Take().
|
inline |
|
private |
The length of the allocated buffer memory space.
Definition at line 175 of file mwdata.h.
Referenced by IncreaseBuffer(), mwData(), operator=(), Reset(), Swap(), and Take().
|
private |
The data buffer.
Definition at line 169 of file mwdata.h.
Referenced by Append(), AppendBytes(), Buffer(), Current(), IncreaseBuffer(), mwData(), operator=(), Reset(), Retrieve(), RetrieveBytes(), SkipString(), Swap(), Take(), and ~mwData().
|
private |
The length of the data in the buffer and the write position.
Definition at line 172 of file mwdata.h.
Referenced by Append(), AppendBytes(), IncreaseBuffer(), Length(), mwData(), operator=(), Position(), Reset(), Retrieve(), RetrieveBytes(), SkipString(), Swap(), and Take().
|
private |
The current read position in the buffer.
Definition at line 178 of file mwdata.h.
Referenced by Current(), mwData(), operator=(), Position(), Reset(), Retrieve(), RetrieveBytes(), Rewind(), SkipString(), Swap(), and Take().