RSTT
3.2.0
Regional Seismic Travel Time
|
A byte array container used to hold binary data in the same manner as disk based file system. More...
#include <DataBuffer.h>
Public Member Functions | |
DataBuffer () | |
DataBuffer (bool doPad) | |
DataBuffer (string *str) | |
DataBuffer (const DataBuffer &db) | |
virtual | ~DataBuffer () |
DataBuffer & | operator= (const DataBuffer &db) |
void | dumpBuffer () |
void | writeToFile (ofstream &ofs) |
void | writeToFile (fstream &ofs) |
void | readFromFile (fstream &ifs, int num_bytes) |
void | readFromFile (ifstream &ifs, int num_bytes) |
void | readFromFile (fstream &ifs, int64 filePos, int num_bytes) |
void | readFromFile (ifstream &ifs, int64 filePos, int num_bytes) |
const string & | readMD5HashKey () |
string | generateMD5HashKey () |
string | generateDataBufMD5HashKey () |
void | align4Byte () |
Aligns the DataBuffer position pointer on a 4 byte boundary if it is not currently aligned as such. More... | |
void | align8Byte () |
Aligns the DataBuffer position pointer on an 8 byte boundary if it is not currently aligned as such. More... | |
void | checkBufferSize (int sincr) |
Checks the current buffer storage size and increments to see if it can contain sincr more bytes. If not it increments the size so that sincr bytes can be added safely. More... | |
void | clear () |
Clear the DataBuffer. More... | |
const string & | readString () |
Read a string and return a reference to be assigned to another string in the client. This function assumes the length of the string occurs imediately before the actual string data. More... | |
void | readString (string &str, int num_chars) |
Read num_chars from 'this' databuffer into the input string, str. More... | |
void | readCharArray (char *array, int num_chars) |
Read num_chars characters from 'this' DataBuffer into /em array. More... | |
uByte | readByte () |
Read a byte from the buffer and update the iterator. More... | |
uByte | readByte (int pos) |
Read a byte from the positions specified by pos ... doesn't update dbDataPos. More... | |
void | readByteArray (uByte *array, int num_bytes) |
Read num_bytes characters from 'this' DataBuffer into array. More... | |
bool | readBool () |
Read a bool from the buffer and update the iterator. More... | |
bool | readBool (int pos) |
Read a bool from the positions specified by pos ... doesn't update dbDataPos. More... | |
void | readBoolArray (bool *array, int num_bools) |
Read num_bools booleans from 'this' DataBuffer into array. More... | |
int | readInt32 () |
Read an int from the buffer. Make sure the buffer is 4byte alligned before reading. More... | |
int | readInt32 (int pos) |
Read the int from the positions specified by pos ... doesn't update dbDataPos. More... | |
int | readRawInt32 () |
Read an Int32 ... don't check for alignment ... fast but client is responsible for alignment. More... | |
void | readIntArray (int *array, int num_ints) |
Read num_ints integers from 'this' DataBuffer into array. More... | |
int64 | readInt64 () |
Read a long from the buffer. Make sure the buffer is 8byte alligned before reading. More... | |
int64 | readInt64 (int pos) |
Read the long from the positions specified by pos ... doesn't update dbDataPos. More... | |
int64 | readRawInt64 () |
Read a long ... don't check for alignment ... fast but client is responsible for alignment. More... | |
void | readLongArray (int64 *array, int num_longs) |
Read num_longs int64s from 'this' DataBuffer into array. More... | |
float | readFloat () |
Read a float from the buffer. Make sure the buffer is 4byte alligned before reading. More... | |
float | readFloat (int pos) |
Read the float from the positions specified by pos ... doesn't update dbDataPos. More... | |
float | readRawFloat () |
Read a float ... don't check for alignment ... fast but client is responsible for alignment. More... | |
void | readFloatArray (float *array, int num_floats) |
Read num_floats floats from 'this' DataBuffer into array. More... | |
double | readDouble () |
Read a double from the buffer. Make sure the buffer is 8byte alligned before reading. More... | |
double | readDouble (int pos) |
Just read the double from the positions specified by pos ... doesn't update dbDataPos. More... | |
double | readRawDouble () |
Read a double ... don't check for alignment ... fast but client is responsible for alignment. More... | |
void | readDoubleArray (double *array, int num_doubles) |
Read num_doubles doubles from 'this' DataBuffer into array. More... | |
void | writeString (const string &in_string) |
Write the string in_string into 'this' DataBuffer. More... | |
void | writeString (char *char_string) |
Write the string char_string into 'this' DataBuffer. More... | |
void | writeCharArray (const char *array, int num_chars) |
Write num_chars of the character array into 'this' DataBuffer. More... | |
void | writeByte (uByte b) |
Write a byte (b) to the DataBuffer. Make sure the buffer is sized appropriately before writing. More... | |
void | writeByte (uByte b, int pos) |
Write a uByte (b) at databuffer position pos. Does not update the iterator. More... | |
void | writeRawByte (uByte b) |
Write a uByte (b) ... don't check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly. More... | |
void | writeByteArray (const uByte *array, int num_bytes) |
Write num_bytes uBytes from the input array into 'this' DataBuffer. More... | |
void | writeBool (bool b) |
Write a bool (b) to the DataBuffer. Make sure the buffer is sized appropriately before writing. More... | |
void | writeBool (bool b, int pos) |
Write a bool (b) at databuffer position pos. Does not update the iterator. More... | |
void | writeRawBool (bool b) |
Write a bool (b) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly. More... | |
void | writeBoolArray (const bool *array, int num_bools) |
Write num_bools bools from the input array into 'this' DataBuffer. More... | |
void | writeInt32 (int i) |
Write an Int32 (i) to the DataBuffer. Make sure the buffer is 4byte alligned and sized appropriatly before reading. More... | |
void | writeInt32 (int i, int pos) |
Write an int (i) at databuffer position pos. Do not update the iterator. More... | |
void | writeRawInt32 (int i) |
Write an Int32 (i) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly. More... | |
void | writeIntArray (const int *array, int num_ints) |
Write num_ints ints from the input array into 'this' DataBuffer. More... | |
void | writeInt64 (int64 i) |
Write an Int64 (i) to the DataBuffer. Make sure the buffer is 8byte alligned and sized appropriatly before reading. More... | |
void | writeInt64 (int64 i, int pos) |
Write a long (i) at databuffer position pos. Does not update the iterator. More... | |
void | writeRawInt64 (int64 i) |
Write an Int64 (i) ... don't check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly. More... | |
void | writeLongArray (const int64 *array, int num_longs) |
Write num_longs longs from the input array into 'this' DataBuffer. More... | |
void | writeFloat (float f) |
Write a float (f) to the DataBuffer. Make sure the buffer is 4byte alligned and sized appropriatly before reading. More... | |
void | writeFloat (float f, int pos) |
Write a float (f) at databuffer position pos. Does not update the iterator. More... | |
void | writeRawFloat (float f) |
Write a float (f) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly. More... | |
void | writeFloatArray (const float *array, int num_floats) |
Write num_floats floats from the input array into 'this' DataBuffer. More... | |
void | writeDouble (double d) |
Write a double (d) to the DataBuffer. Make sure the buffer is 8byte alligned and sized appropriatly before reading. More... | |
void | writeDouble (double d, int pos) |
Write a double (d) at databuffer position pos. Does not update the iterator. More... | |
void | writeRawDouble (double d) |
Write a double (d) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly. More... | |
void | writeDoubleArray (const double *array, int num_doubles) |
Write num_doubles doubles from the input array into 'this' DataBuffer. More... | |
virtual string | get_class_name () const |
Returns the class name. More... | |
virtual int | class_size () const |
Returns the class size (in bytes). More... | |
void | setSize (int num_bytes) |
Set the size of the data buffer to num_bytes. More... | |
int | size () |
Return the current DataBuffer size. More... | |
void | resetPos () |
Reset the buffers iterator location to zero. More... | |
void | setPosToEnd () |
Set the buffers iterator position to dbSize. If current iterator exceeds dbsize then dbsize is set and dbDataPos is unchanged. More... | |
int | getPos () const |
Return the buffers iterator location. More... | |
void | incrementPos (int increment) |
Increment the buffers iterator by increment bytes. This is an unsafe operation. If dbDataPos + increment > dbSize. dbSize is NOT checked. More... | |
void | decrementPos (int decrement) |
Decrement the buffers iterator by decrement bytes. This is an unsafe operation. If dbDataPos - decrement < 0. More... | |
string | getData () const |
Return a reference to the DataBuffer. More... | |
int | getCapacity () const |
Return allocated capacity of 'this' DataBuffer. More... | |
char * | getPosPointer () |
Return a pointer to the current iterator location in the buffer. More... | |
char * | getPosPointer (int pos) |
Return a Pointer to position pos in the buffer. More... | |
void | setByteOrderReverse (bool bor) |
Sets the byte order reverse flag to bor. More... | |
void | byteOrderReverseOn () |
Sets the byte order reverse flag to true. More... | |
void | byteOrderReverseOff () |
Sets the byte order reverse flag to false. More... | |
bool | isByteOrderReversed () const |
Returns true if the byte order in reads and writes is reversed for all 2, 4, or 8 byte intrinsincs (short, int, long, float, double, etc.). More... | |
void | reserve (int sze) |
brief Reserves space in the DataBuffer More... | |
Static Public Member Functions | |
static void | reverseBOArray (int n, char *a, int s) |
static void | reverseBO2Array (int n, char *a) |
static void | reverseBO4Array (int n, char *a) |
static void | reverseBO8Array (int n, char *a) |
static void | reverseBO2 (char *d) |
Reverses byte order of d. d is assumed to point to an 2 byte element. More... | |
static void | reverseBO4 (char *d) |
Reverses byte order of d. d is assumed to point to an 4 byte element. More... | |
static void | reverseBO8 (char *d) |
Reverses byte order of d. d is assumed to point to an 8 byte element. More... | |
static string | class_name () |
Static function that returns the class name. More... | |
static int | getAllocationReqSize () |
Static Public Attributes | |
static const int | ALLOCATION_REQ_SIZE |
Default allocation requirement size for a data buffer. More... | |
Protected Attributes | |
string * | dbData |
A string object is used to contain the actual data. More... | |
int | dbDataPos |
The current iterator position in the data container (dbData). More... | |
int | dbSize |
The current size of the data container. More... | |
bool | dbPad |
A boolean, that if true, maintains 4 and 8 byte alignment in support of double alignment compilation. More... | |
bool | dbReverse |
A boolean, that if true, reverses the byte order of all 2, 4, and 8 byte intrinsics (shorts, ints, long, floats, doubles, etc.). This flag is set by the FileDatabase object only and otherwise defaults to false. The flag is used to convert byte order between big- and little- endian formats. More... | |
bool | dbOwnStr |
A boolean, that if true, indicates the storage string for this DataBuffer is owned and therefore deleted when the DataBuffer is deleted. More... | |
A byte array container used to hold binary data in the same manner as disk based file system.
The object contains a padding facility to maintain 1, 4, and 8 byte aligned objects so that the objects that utilize this class can be compiled as doubly aligned. This object is used extensively in support of database object serialization. The class contains a long list of methods and properties supporting read/write capability for string, char, byte, bool, int, long, float, and double types. Most types also contain an array read/write capability. Finally, the ability to read and write compressed data is provided using the zlib library facility.
Definition at line 80 of file DataBuffer.h.
util::DataBuffer::DataBuffer | ( | ) |
util::DataBuffer::DataBuffer | ( | bool | doPad | ) |
util::DataBuffer::DataBuffer | ( | string * | str | ) |
util::DataBuffer::DataBuffer | ( | const DataBuffer & | db | ) |
|
virtual |
|
inline |
Aligns the DataBuffer position pointer on a 4 byte boundary if it is not currently aligned as such.
Definition at line 437 of file DataBuffer.h.
|
inline |
Aligns the DataBuffer position pointer on an 8 byte boundary if it is not currently aligned as such.
Definition at line 454 of file DataBuffer.h.
|
inline |
Sets the byte order reverse flag to false.
Definition at line 1596 of file DataBuffer.h.
|
inline |
Sets the byte order reverse flag to true.
Definition at line 1586 of file DataBuffer.h.
|
inline |
Checks the current buffer storage size and increments to see if it can contain sincr more bytes. If not it increments the size so that sincr bytes can be added safely.
Definition at line 472 of file DataBuffer.h.
|
inlinestatic |
Static function that returns the class name.
Definition at line 406 of file DataBuffer.h.
|
inlinevirtual |
Returns the class size (in bytes).
Definition at line 426 of file DataBuffer.h.
|
inline |
Clear the DataBuffer.
Definition at line 486 of file DataBuffer.h.
|
inline |
Decrement the buffers iterator by decrement bytes. This is an unsafe operation. If dbDataPos - decrement < 0.
Definition at line 1472 of file DataBuffer.h.
void util::DataBuffer::dumpBuffer | ( | ) |
string util::DataBuffer::generateDataBufMD5HashKey | ( | ) |
string util::DataBuffer::generateMD5HashKey | ( | ) |
|
inlinevirtual |
Returns the class name.
Definition at line 416 of file DataBuffer.h.
|
static |
|
inline |
Return allocated capacity of 'this' DataBuffer.
Definition at line 1492 of file DataBuffer.h.
|
inline |
Return a reference to the DataBuffer.
Definition at line 1482 of file DataBuffer.h.
|
inline |
Return the buffers iterator location.
Definition at line 1449 of file DataBuffer.h.
|
inline |
Return a pointer to the current iterator location in the buffer.
Definition at line 1502 of file DataBuffer.h.
|
inline |
Return a Pointer to position pos in the buffer.
Definition at line 1513 of file DataBuffer.h.
|
inline |
Increment the buffers iterator by increment bytes. This is an unsafe operation. If dbDataPos + increment > dbSize. dbSize is NOT checked.
Definition at line 1461 of file DataBuffer.h.
|
inline |
Returns true if the byte order in reads and writes is reversed for all 2, 4, or 8 byte intrinsincs (short, int, long, float, double, etc.).
Definition at line 1607 of file DataBuffer.h.
DataBuffer& util::DataBuffer::operator= | ( | const DataBuffer & | db | ) |
|
inline |
Read a bool from the buffer and update the iterator.
Definition at line 590 of file DataBuffer.h.
|
inline |
Read a bool from the positions specified by pos ... doesn't update dbDataPos.
Definition at line 605 of file DataBuffer.h.
|
inline |
Read num_bools booleans from 'this' DataBuffer into array.
Definition at line 618 of file DataBuffer.h.
|
inline |
Read a byte from the buffer and update the iterator.
Definition at line 549 of file DataBuffer.h.
|
inline |
Read a byte from the positions specified by pos ... doesn't update dbDataPos.
Definition at line 564 of file DataBuffer.h.
|
inline |
Read num_bytes characters from 'this' DataBuffer into array.
Definition at line 577 of file DataBuffer.h.
|
inline |
Read num_chars characters from 'this' DataBuffer into /em array.
Definition at line 536 of file DataBuffer.h.
|
inline |
Read a double from the buffer. Make sure the buffer is 8byte alligned before reading.
Definition at line 835 of file DataBuffer.h.
|
inline |
Just read the double from the positions specified by pos ... doesn't update dbDataPos.
Definition at line 852 of file DataBuffer.h.
|
inline |
Read num_doubles doubles from 'this' DataBuffer into array.
Definition at line 882 of file DataBuffer.h.
|
inline |
Read a float from the buffer. Make sure the buffer is 4byte alligned before reading.
Definition at line 767 of file DataBuffer.h.
|
inline |
Read the float from the positions specified by pos ... doesn't update dbDataPos.
Definition at line 784 of file DataBuffer.h.
|
inline |
Read num_floats floats from 'this' DataBuffer into array.
Definition at line 814 of file DataBuffer.h.
void util::DataBuffer::readFromFile | ( | fstream & | ifs, |
int | num_bytes | ||
) |
void util::DataBuffer::readFromFile | ( | fstream & | ifs, |
int64 | filePos, | ||
int | num_bytes | ||
) |
void util::DataBuffer::readFromFile | ( | ifstream & | ifs, |
int | num_bytes | ||
) |
void util::DataBuffer::readFromFile | ( | ifstream & | ifs, |
int64 | filePos, | ||
int | num_bytes | ||
) |
|
inline |
Read an int from the buffer. Make sure the buffer is 4byte alligned before reading.
Definition at line 632 of file DataBuffer.h.
|
inline |
Read the int from the positions specified by pos ... doesn't update dbDataPos.
Definition at line 649 of file DataBuffer.h.
|
inline |
Read a long from the buffer. Make sure the buffer is 8byte alligned before reading.
Definition at line 699 of file DataBuffer.h.
|
inline |
Read the long from the positions specified by pos ... doesn't update dbDataPos.
Definition at line 716 of file DataBuffer.h.
|
inline |
Read num_ints integers from 'this' DataBuffer into array.
Definition at line 679 of file DataBuffer.h.
|
inline |
Read num_longs int64s from 'this' DataBuffer into array.
Definition at line 746 of file DataBuffer.h.
const string& util::DataBuffer::readMD5HashKey | ( | ) |
|
inline |
Read a double ... don't check for alignment ... fast but client is responsible for alignment.
Definition at line 867 of file DataBuffer.h.
|
inline |
Read a float ... don't check for alignment ... fast but client is responsible for alignment.
Definition at line 799 of file DataBuffer.h.
|
inline |
Read an Int32 ... don't check for alignment ... fast but client is responsible for alignment.
Definition at line 664 of file DataBuffer.h.
|
inline |
Read a long ... don't check for alignment ... fast but client is responsible for alignment.
Definition at line 731 of file DataBuffer.h.
|
inline |
Read a string and return a reference to be assigned to another string in the client. This function assumes the length of the string occurs imediately before the actual string data.
Definition at line 504 of file DataBuffer.h.
|
inline |
Read num_chars from 'this' databuffer into the input string, str.
Definition at line 523 of file DataBuffer.h.
|
inline |
brief Reserves space in the DataBuffer
Reserves space in the DataBuffer.
Definition at line 1619 of file DataBuffer.h.
|
inline |
Reset the buffers iterator location to zero.
Definition at line 1421 of file DataBuffer.h.
|
inlinestatic |
Reverses byte order of d. d is assumed to point to an 2 byte element.
Definition at line 1524 of file DataBuffer.h.
|
static |
|
inlinestatic |
Reverses byte order of d. d is assumed to point to an 4 byte element.
Definition at line 1536 of file DataBuffer.h.
|
static |
|
inlinestatic |
Reverses byte order of d. d is assumed to point to an 8 byte element.
Definition at line 1552 of file DataBuffer.h.
|
static |
|
static |
|
inline |
Sets the byte order reverse flag to bor.
Definition at line 1576 of file DataBuffer.h.
|
inline |
Set the buffers iterator position to dbSize. If current iterator exceeds dbsize then dbsize is set and dbDataPos is unchanged.
Definition at line 1436 of file DataBuffer.h.
|
inline |
Set the size of the data buffer to num_bytes.
Definition at line 1396 of file DataBuffer.h.
|
inline |
Return the current DataBuffer size.
Definition at line 1406 of file DataBuffer.h.
|
inline |
Write a bool (b) to the DataBuffer. Make sure the buffer is sized appropriately before writing.
Definition at line 1030 of file DataBuffer.h.
|
inline |
Write a bool (b) at databuffer position pos. Does not update the iterator.
Definition at line 1047 of file DataBuffer.h.
|
inline |
Write num_bools bools from the input array into 'this' DataBuffer.
Definition at line 1074 of file DataBuffer.h.
|
inline |
Write a byte (b) to the DataBuffer. Make sure the buffer is sized appropriately before writing.
Definition at line 968 of file DataBuffer.h.
|
inline |
Write a uByte (b) at databuffer position pos. Does not update the iterator.
Definition at line 985 of file DataBuffer.h.
|
inline |
Write num_bytes uBytes from the input array into 'this' DataBuffer.
Definition at line 1012 of file DataBuffer.h.
|
inline |
Write num_chars of the character array into 'this' DataBuffer.
Definition at line 950 of file DataBuffer.h.
|
inline |
Write a double (d) to the DataBuffer. Make sure the buffer is 8byte alligned and sized appropriatly before reading.
Definition at line 1317 of file DataBuffer.h.
|
inline |
Write a double (d) at databuffer position pos. Does not update the iterator.
Definition at line 1338 of file DataBuffer.h.
|
inline |
Write num_doubles doubles from the input array into 'this' DataBuffer.
Definition at line 1368 of file DataBuffer.h.
|
inline |
Write a float (f) to the DataBuffer. Make sure the buffer is 4byte alligned and sized appropriatly before reading.
Definition at line 1242 of file DataBuffer.h.
|
inline |
Write a float (f) at databuffer position pos. Does not update the iterator.
Definition at line 1263 of file DataBuffer.h.
|
inline |
Write num_floats floats from the input array into 'this' DataBuffer.
Definition at line 1292 of file DataBuffer.h.
|
inline |
Write an Int32 (i) to the DataBuffer. Make sure the buffer is 4byte alligned and sized appropriatly before reading.
Definition at line 1092 of file DataBuffer.h.
|
inline |
Write an int (i) at databuffer position pos. Do not update the iterator.
Definition at line 1113 of file DataBuffer.h.
|
inline |
Write an Int64 (i) to the DataBuffer. Make sure the buffer is 8byte alligned and sized appropriatly before reading.
Definition at line 1167 of file DataBuffer.h.
|
inline |
Write a long (i) at databuffer position pos. Does not update the iterator.
Definition at line 1188 of file DataBuffer.h.
|
inline |
Write num_ints ints from the input array into 'this' DataBuffer.
Definition at line 1142 of file DataBuffer.h.
|
inline |
Write num_longs longs from the input array into 'this' DataBuffer.
Definition at line 1217 of file DataBuffer.h.
|
inline |
Write a bool (b) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly.
Definition at line 1061 of file DataBuffer.h.
|
inline |
Write a uByte (b) ... don't check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly.
Definition at line 999 of file DataBuffer.h.
|
inline |
Write a double (d) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly.
Definition at line 1353 of file DataBuffer.h.
|
inline |
Write a float (f) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly.
Definition at line 1278 of file DataBuffer.h.
|
inline |
Write an Int32 (i) ... do not check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly.
Definition at line 1128 of file DataBuffer.h.
|
inline |
Write an Int64 (i) ... don't check for alignment or size ... fast but the client is responsible for handling alignment and sizing correctly.
Definition at line 1203 of file DataBuffer.h.
|
inline |
Write the string char_string into 'this' DataBuffer.
Definition at line 939 of file DataBuffer.h.
|
inline |
Write the string in_string into 'this' DataBuffer.
Definition at line 906 of file DataBuffer.h.
void util::DataBuffer::writeToFile | ( | fstream & | ofs | ) |
void util::DataBuffer::writeToFile | ( | ofstream & | ofs | ) |
|
static |
Default allocation requirement size for a data buffer.
Definition at line 359 of file DataBuffer.h.
|
protected |
A string object is used to contain the actual data.
Definition at line 373 of file DataBuffer.h.
|
protected |
The current iterator position in the data container (dbData).
Definition at line 376 of file DataBuffer.h.
|
protected |
A boolean, that if true, indicates the storage string for this DataBuffer is owned and therefore deleted when the DataBuffer is deleted.
Definition at line 395 of file DataBuffer.h.
|
protected |
A boolean, that if true, maintains 4 and 8 byte alignment in support of double alignment compilation.
Definition at line 383 of file DataBuffer.h.
|
protected |
A boolean, that if true, reverses the byte order of all 2, 4, and 8 byte intrinsics (shorts, ints, long, floats, doubles, etc.). This flag is set by the FileDatabase object only and otherwise defaults to false. The flag is used to convert byte order between big- and little- endian formats.
Definition at line 390 of file DataBuffer.h.
|
protected |
The current size of the data container.
Definition at line 379 of file DataBuffer.h.