#include <CkptByteArray.h>
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. |
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.
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.
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.
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] |
bool CkptByteArray::writeBytes | ( | char * | userBuffer, | |
unsigned int | numBytes | |||
) | [inline] |
Appends the data from the user buffer to the end of the byte array.
userBuffer | - the pointer to a user buffer, from which the data is copied | |
numBytes | - the number of bytes to be copied from the userBuffer |
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.
userBuffer | - pointer to a user buffer, where the data is copied | |
numBytes | - the number of bytes to be copied into 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] |
bool CkptByteArray::write | ( | short & | sValue | ) | [inline] |
bool CkptByteArray::write | ( | double & | dValue | ) | [inline] |
bool CkptByteArray::write | ( | float & | fValue | ) | [inline] |
bool CkptByteArray::write | ( | char & | cValue | ) | [inline] |
bool CkptByteArray::write | ( | unsigned long & | ulValue | ) | [inline] |
bool CkptByteArray::write | ( | unsigned int & | uiValue | ) | [inline] |
bool CkptByteArray::write | ( | unsigned short & | usValue | ) | [inline] |
bool CkptByteArray::write | ( | unsigned char & | ucValue | ) | [inline] |
bool CkptByteArray::write | ( | std::string & | str | ) | [inline] |
long CkptByteArray::readLong | ( | ) | [inline] |
int CkptByteArray::readInt | ( | ) | [inline] |
short CkptByteArray::readShort | ( | ) | [inline] |
double CkptByteArray::readDouble | ( | ) | [inline] |
float CkptByteArray::readFloat | ( | ) | [inline] |
char CkptByteArray::readChar | ( | ) | [inline] |
unsigned long CkptByteArray::readULong | ( | ) | [inline] |
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] |
unsigned char CkptByteArray::readUChar | ( | ) | [inline] |
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().
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().