Class that represents a binary serialization buffer, using native byte ordering. More...
#include <SPL/Runtime/Serialization/NativeByteBuffer.h>
Public Member Functions |
|
NativeByteBuffer () | |
NativeByteBuffer (uint64_t initialSize) | |
NativeByteBuffer (unsigned char *mybuf, uint64_t mysize) | |
NativeByteBuffer (NativeByteBuffer const &sb) | |
NativeByteBuffer (NativeByteBuffer &sb, bool isDestructive) | |
~NativeByteBuffer () | |
NativeByteBuffer & | assign (NativeByteBuffer const &sb) |
NativeByteBuffer & | copyData (NativeByteBuffer const &sb) |
void | addChar (char ch) |
char | getChar () |
void | addBool (bool b) |
bool | getBool () |
void | addUInt8 (uint8_t i) |
uint8_t | getUInt8 () |
void | addInt8 (int8_t i) |
int8_t | getInt8 () |
void | addUInt16 (uint16_t i) |
uint16_t | getUInt16 () |
void | addInt16 (int16_t i) |
int16_t | getInt16 () |
void | addUInt32 (uint32_t i) |
uint32_t | getUInt32 () |
void | addInt32 (int32_t i) |
int32_t | getInt32 () |
void | addUInt64 (uint64_t i) |
uint64_t | getUInt64 () |
void | addInt64 (int64_t i) |
int64_t | getInt64 () |
void | addFloat (float f) |
float | getFloat () |
void | addDouble (double d) |
double | getDouble () |
void | addLongDouble (long double d) |
long double | getLongDouble () |
void | addNTStr (char const *str) |
char * | getNTStr () |
void | addSTLString (std::string const &str) |
std::string | getSTLString () |
void | getSTLString (std::string &str) |
void | addSPLString (RSTRING_BB_TYPE const &str) |
RSTRING_BB_TYPE | getSPLString () |
void | getSPLString (RSTRING_BB_TYPE &str) |
void | addUnicodeString (USTRING_BB_TYPE const &ustr) |
USTRING_BB_TYPE | getUnicodeString () |
void | addBlob (void const *blob, uint32_t bsize) |
unsigned char * | getBlob (uint32_t &mysize) |
void | addCharSequence (char const *chsbuf, uint32_t chssize) |
char * | getCharSequence (uint32_t &sizeTillEOB) |
char * | getFixedCharSequence (uint32_t mysize) |
void | addPointer (void const *ptr) |
void * | getPointer () |
void | setICursor (uint64_t off) |
uint64_t | getICursor () const |
uint64_t | getContentSize () const |
uint64_t | getSize () const |
void | setOCursor (uint64_t off) |
uint64_t | getOCursor () const |
uint64_t | getNRemainingBytes () const |
unsigned char * | getPtr () |
unsigned char const * | getPtr () const |
uint64_t | getSerializedDataSize () const |
void | setAutoDealloc (bool myAutoDealloc) |
bool | operator== (NativeByteBuffer const &b) const |
bool | operator!= (NativeByteBuffer const &b) const |
Class that represents a binary serialization buffer, using native byte ordering.
Objects can be serialiazed into the buffer or de-serialized from the buffer in binary form. In a typical case, the underlying memory is managed (allocated/resized/deallocated) by the NativeByteBuffer class. Such a behavior can be changed by handing a buffer to the constructor that takes an externally allocated buffer. In such case the underlying memory will have to be deallocated externally, unless setAutoDealloc is invoked to re-assign the memory management tasks to the class.
Important note: This class is highly optimized for speed, and thus does not perform any bounds checking for its operations.
SPL::NativeByteBuffer::NativeByteBuffer | ( | ) |
Default Constructor
SPL::NativeByteBuffer::NativeByteBuffer | ( | uint64_t | initialSize | ) |
Constructor
initialSize | buffer initial size (the buffer is automatically resized when necessary if autoDealloc is true, i.e., the buffer itself has not been externally alloced) |
SPL::NativeByteBuffer::NativeByteBuffer | ( | unsigned char * | mybuf, |
uint64_t | mysize | ||
) |
Constructor – used for handing externally allocated buffers to NativeByteBuffer (the default behavior is for the memory management capabilities to reside with the external entity, i.e., by default memory will have to be deallocated externally). The input cursor for serialization is initialized to point to the end of the buffer, and the output cursor for deserialization is initialized to point to the beginning of the buffer.
mybuf | an externally allocated buffer |
mysize | the buffer size (this buffer is allocated externally – resizings can only be done later if autoDealloc is set to be true) |
SPL::NativeByteBuffer::NativeByteBuffer | ( | NativeByteBuffer const & | sb | ) |
Copy constructor
sb | an existing NativeByteBuffer object |
SPL::NativeByteBuffer::NativeByteBuffer | ( | NativeByteBuffer & | sb, |
bool | isDestructive | ||
) |
Destructive copy Constructor
sb | an existing NativeByteBuffer object |
isDestructive | true means that the original object will be destroyed (i.e., the internal buffer for the original buffer will be nullified) |
SPL::NativeByteBuffer::~NativeByteBuffer | ( | ) |
Destructor
NativeByteBuffer& SPL::NativeByteBuffer::assign | ( | NativeByteBuffer const & | sb | ) |
Assign a serialization buffer object to another
sb | an existing NativeByteBuffer object |
NativeByteBuffer& SPL::NativeByteBuffer::copyData | ( | NativeByteBuffer const & | sb | ) |
Copy the serialized contents of another buffer object Do not change any properties of the buffer, just the data gets copied
sb | an existing NativeByteBuffer object |
|
inline |
Add/serialize a character to the serialization buffer
ch | a character |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a character from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a boolean to the serialization buffer
b | a boolean |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a boolean from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an uint8_t to the serialization buffer
i | a uint8_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an uint8_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an int8_t to the serialization buffer
i | an int8_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an int8_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an uint16_t to the serialization buffer
i | a uint16_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a uint16_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an int16_t to the serialization buffer
i | an int16_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an int16_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an uint32_t to the serialization buffer
i | a uint32_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a uint32_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an int32_t to the serialization buffer
i | an int32_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an int32_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a uint64_t to the serialization buffer
i | a uint64_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a uint64_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an int64_t to the serialization buffer
i | an int64_t |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an int64_t from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a float to the serialization buffer
f | a single-precision floating point number |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a float from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a double to the serialization buffer
d | a double-precision floating point number |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a double from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a long double to the serialization buffer
d | a long double floating point number |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a long double from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a NULL-terminated string to the serialization buffer
str | a NULL terminated string |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a NULL-terminated string from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an STL string to the serialization buffer
str | an STL string |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an STL string from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an STL string from the serialization buffer
str | STL string to be extracted |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an SPL string to the serialization buffer
str | an SPL string |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an SPL string from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an SPL string from the serialization buffer
str | SPL string to be extracted |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a ustring to the serialization buffer
ustr | a ustring |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
USTRING_BB_TYPE SPL::NativeByteBuffer::getUnicodeString | ( | ) |
Extract/de-serialize a ustring from the serialization buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize an opaque blob to the serialization buffer
blob | a pointer to an opaque blob |
bsize | the opaque blob size |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize an opaque blob from the serialization buffer
mysize | the size of the returned opaque blob |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a sequence of characters to the serialization buffer NOTE: the size of the sequence is not serialized (for that use addBlob)
chsbuf | a pointer to a sequence of characters |
chssize | the size for the sequence of characters |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a sequence of characters from the serialization buffer – the sequence begins at the output cursor position and ends at the end of the serialization buffer
sizeTillEOB | the size of the sequence until the end of the serialization buffer |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a fixed-size sequence of characters from the serialization buffer – the sequence begins at the output cursor position
mysize | the size of the sequence serialization buffer |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Add/serialize a pointer to the serialization buffer
ptr | a void* pointer |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Extract/de-serialize a pointer from the serialization buffer
a | SPLRuntimeDeserializationException if a pointer cannot be extracted from the buffer |
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Set the cursor for the next serialization operation
off | the new offset |
|
inline |
Get the internal buffer input cursor
|
inline |
Obtain the size of the content currently in the buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Obtain the size of the buffer
|
inline |
Set the cursor for the next de-serialization operation
off | the new offset |
|
inline |
Get the internal buffer output cursor
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Obtain number of serialized bytes remaining from the location pointed by the output cursor till the end of the buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Obtain the pointer for the internal buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Obtain the (const) pointer for the internal buffer
Reimplemented from SPL::ByteBuffer< NativeByteBuffer >.
|
inline |
Obtain the actual size of the serialized data (as opposed to the size of the serialization buffer)
|
inline |
Set/reset the auto deallocation flag (true means that the buffer is self-managed and false means that the buffer is externally managed/owned)
myAutoDealloc | the new value for the auto deallocation flag |
bool SPL::NativeByteBuffer::operator== | ( | NativeByteBuffer const & | b | ) | const |
Equality Operator, checks if the buffer size and binary contents are the same
b | the sbuffer with which we are checking equality with |
|
inline |
Inequality operator, checks if the buffer size and binary contents are the same
b | the sbuffer with which we are checking equality with |