CkptByteArray Class Reference

Container supporting raw byte data manipulation. More...

#include <CkptByteArray.h>

List of all members.

Public Member Functions

 CkptByteArray ()
 CkptByteArray (unsigned int size)
 Create a byte array with a presized data buffer.
 CkptByteArray (char *buf, unsigned int bufSize)
 Create a pre-filled byte array.
 ~CkptByteArray ()
void resetPtr ()
char * getDataPtr ()
unsigned int getDataSize ()
unsigned int bytesRemaining ()
General read/write methods
bool writeBytes (char *userBuffer, unsigned int numBytes)
 Appends the data from the user buffer to the end of the byte array.
int readBytes (char *userBuffer, unsigned int numBytes)
 Read bytes into the user supplied buffer.
Typed write methods
Methods for writing a primitive type to the raw CkptByteArray buffer.

Appends the raw bytes representing the type specified.

bool write (long &lValue)
bool write (int &iValue)
bool write (short &sValue)
bool write (double &dValue)
bool write (float &fValue)
bool write (char &cValue)
bool write (unsigned long &ulValue)
bool write (unsigned int &uiValue)
bool write (unsigned short &usValue)
bool write (unsigned char &ucValue)
bool write (std::string &str)
Typed read methods
Methods for reading a primitive type from the raw CkptByteArray buffer.

Returns the next piece of data in the buffer, interpreted as the type specified, and moves an internal pointer to the next piece.

long readLong ()
int readInt ()
short readShort ()
double readDouble ()
float readFloat ()
char readChar ()
unsigned long readULong ()
unsigned int readUInt ()
unsigned short readUShort ()
unsigned char readUChar ()
std::string readString ()

Private Member Functions

bool grow ()

Private Attributes

unsigned int _bufferSize
unsigned int _dataSize
 The size of our buffer in RAM. This can grow as needed.
char * _dataBuffer
 The actual size of the data written.
char * _currDataPtr
 The pointer to the start of the data buffer.

Static Private Attributes

static const unsigned int MIN_BUFFER_SIZE = 64
 Default starting size (in bytes) for the data buffer.
static const unsigned int GROWTH_SIZE = MIN_BUFFER_SIZE
 Increment (in bytes) by which the buffer grows as needed.


Detailed Description

Container supporting raw byte data manipulation.

Used by subclasses of CkptObject for serialization and deserialization. It functions as a raw byte container class, resizable on demand, with methods to handle the appending/reading of primitive data types into/from the byte array. Writing/reading non-primitive data objects (structs, arrays, etc) is supported by the writeBytes() and readBytes() methods, respectively.

 A series of write operations would be performed in a serialize routine:
   // Creation of a CkptByteArray 
   bArray.writeInt(myIntVar);
   bArray.writeLong(myLongVar);
 and subsequently read in a deserialize routine (bArray would be passed in):
   myIntVar = bArray.readInt();
   myLongVar = bArray.readLong();
 

Definition at line 27 of file CkptByteArray.h.


Constructor & Destructor Documentation

CkptByteArray::CkptByteArray (  )  [inline]

Definition at line 35 of file CkptByteArray.h.

References _bufferSize, _dataBuffer, _dataSize, MIN_BUFFER_SIZE, and resetPtr().

CkptByteArray::CkptByteArray ( unsigned int  size  )  [inline]

Create a byte array with a presized data buffer.

Parameters:
size - the number of bytes for the data buffer

Definition at line 46 of file CkptByteArray.h.

References _bufferSize, _dataBuffer, _dataSize, and resetPtr().

CkptByteArray::CkptByteArray ( char *  buf,
unsigned int  bufSize 
) [inline]

Create a pre-filled byte array.

Constructs a CkptByteArray with the user supplied data.

Parameters:
buf - a pointer to user data
bufSize - the number of bytes to be copied from buf into the CkptByteArray

Definition at line 60 of file CkptByteArray.h.

References _bufferSize, _dataBuffer, _dataSize, and resetPtr().

CkptByteArray::~CkptByteArray (  )  [inline]

Definition at line 68 of file CkptByteArray.h.

References _dataBuffer.


Member Function Documentation

bool CkptByteArray::writeBytes ( char *  userBuffer,
unsigned int  numBytes 
) [inline]

Appends the data from the user buffer to the end of the byte array.

Parameters:
userBuffer - the pointer to a user buffer, from which the data is copied
numBytes - the number of bytes to be copied from the userBuffer
Returns:
true if the write succeeded, false otherwise

Definition at line 82 of file CkptByteArray.h.

References _bufferSize, _currDataPtr, _dataSize, and grow().

Referenced by RawOutputDAO::byteCopy(), and write().

int CkptByteArray::readBytes ( char *  userBuffer,
unsigned int  numBytes 
) [inline]

Read bytes into the user supplied buffer.

Parameters:
userBuffer - pointer to a user buffer, where the data is copied
numBytes - the number of bytes to be copied into userBuffer
Returns:
the number of bytes copied from the byte array to the userBuffer

Definition at line 101 of file CkptByteArray.h.

References _currDataPtr, and bytesRemaining().

Referenced by RawInputDAO::byteCopy(), readString(), readUChar(), readUInt(), readULong(), and readUShort().

bool CkptByteArray::write ( long &  lValue  )  [inline]

Definition at line 115 of file CkptByteArray.h.

References writeBytes().

Referenced by RawOutputDAO::byteCopy(), RawOutputDAO::processExternalObj(), and write().

bool CkptByteArray::write ( int &  iValue  )  [inline]

Definition at line 116 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( short &  sValue  )  [inline]

Definition at line 117 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( double &  dValue  )  [inline]

Definition at line 118 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( float &  fValue  )  [inline]

Definition at line 119 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( char &  cValue  )  [inline]

Definition at line 120 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( unsigned long &  ulValue  )  [inline]

Definition at line 122 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( unsigned int &  uiValue  )  [inline]

Definition at line 123 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( unsigned short &  usValue  )  [inline]

Definition at line 124 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( unsigned char &  ucValue  )  [inline]

Definition at line 127 of file CkptByteArray.h.

References writeBytes().

bool CkptByteArray::write ( std::string &  str  )  [inline]

Definition at line 129 of file CkptByteArray.h.

References write(), and writeBytes().

long CkptByteArray::readLong (  )  [inline]

Definition at line 143 of file CkptByteArray.h.

References _currDataPtr.

int CkptByteArray::readInt (  )  [inline]

Definition at line 144 of file CkptByteArray.h.

References _currDataPtr.

short CkptByteArray::readShort (  )  [inline]

Definition at line 145 of file CkptByteArray.h.

References _currDataPtr.

double CkptByteArray::readDouble (  )  [inline]

Definition at line 146 of file CkptByteArray.h.

References _currDataPtr.

float CkptByteArray::readFloat (  )  [inline]

Definition at line 147 of file CkptByteArray.h.

References _currDataPtr.

char CkptByteArray::readChar (  )  [inline]

Definition at line 148 of file CkptByteArray.h.

References _currDataPtr.

unsigned long CkptByteArray::readULong (  )  [inline]

Definition at line 150 of file CkptByteArray.h.

References readBytes().

unsigned int CkptByteArray::readUInt (  )  [inline]

Definition at line 151 of file CkptByteArray.h.

References readBytes().

Referenced by RawInputDAO::byteCopy(), and readString().

unsigned short CkptByteArray::readUShort (  )  [inline]

Definition at line 152 of file CkptByteArray.h.

References readBytes().

unsigned char CkptByteArray::readUChar (  )  [inline]

Definition at line 153 of file CkptByteArray.h.

References readBytes().

std::string CkptByteArray::readString (  )  [inline]

Definition at line 155 of file CkptByteArray.h.

References readBytes(), and readUInt().

Referenced by RawInputDAO::processExternalObj().

void CkptByteArray::resetPtr (  )  [inline]

Definition at line 166 of file CkptByteArray.h.

References _currDataPtr, and _dataBuffer.

Referenced by CkptByteArray().

char* CkptByteArray::getDataPtr (  )  [inline]

Definition at line 167 of file CkptByteArray.h.

References _dataBuffer.

Referenced by CkptContainer::commit(), and CkptContainer::persist().

unsigned int CkptByteArray::getDataSize (  )  [inline]

Definition at line 168 of file CkptByteArray.h.

References _dataSize.

Referenced by CkptContainer::commit(), and CkptContainer::persist().

unsigned int CkptByteArray::bytesRemaining (  )  [inline]

Definition at line 169 of file CkptByteArray.h.

References _currDataPtr, _dataBuffer, and _dataSize.

Referenced by readBytes().

bool CkptByteArray::grow (  )  [inline, private]

Definition at line 173 of file CkptByteArray.h.

References _bufferSize, _currDataPtr, _dataBuffer, and GROWTH_SIZE.

Referenced by writeBytes().


Member Data Documentation

const unsigned int CkptByteArray::MIN_BUFFER_SIZE = 64 [static, private]

Default starting size (in bytes) for the data buffer.

Definition at line 30 of file CkptByteArray.h.

Referenced by CkptByteArray().

const unsigned int CkptByteArray::GROWTH_SIZE = MIN_BUFFER_SIZE [static, private]

Increment (in bytes) by which the buffer grows as needed.

Definition at line 32 of file CkptByteArray.h.

Referenced by grow().

unsigned int CkptByteArray::_bufferSize [private]

Definition at line 185 of file CkptByteArray.h.

Referenced by CkptByteArray(), grow(), and writeBytes().

unsigned int CkptByteArray::_dataSize [private]

The size of our buffer in RAM. This can grow as needed.

Definition at line 186 of file CkptByteArray.h.

Referenced by bytesRemaining(), CkptByteArray(), getDataSize(), and writeBytes().

char* CkptByteArray::_dataBuffer [private]

The actual size of the data written.

Definition at line 187 of file CkptByteArray.h.

Referenced by bytesRemaining(), CkptByteArray(), getDataPtr(), grow(), resetPtr(), and ~CkptByteArray().

char* CkptByteArray::_currDataPtr [private]

The pointer to the start of the data buffer.

Definition at line 188 of file CkptByteArray.h.

Referenced by bytesRemaining(), grow(), readBytes(), readChar(), readDouble(), readFloat(), readInt(), readLong(), readShort(), resetPtr(), and writeBytes().


The documentation for this class was generated from the following file:
Generated on Fri Apr 27 17:20:01 2007 for aiscoal by  doxygen 1.5.2