VMware GemFire Native C++ Reference  9.1
apache::geode::client::DataOutput Class Reference

Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a byte stream. More...

Public Member Functions

void advanceCursor (uint32_t offset)
 Advance the buffer cursor by the given offset. More...
 
 DataOutput ()
 Construct a new DataOutput. More...
 
const uint8_t * getBuffer () const
 Get a pointer to the internal buffer of DataOutput. More...
 
const uint8_t * getBuffer (uint32_t *rsize) const
 Get a pointer to the internal buffer of DataOutput. More...
 
uint32_t getBufferLength () const
 Get the length of current data in the internal buffer of DataOutput. More...
 
const uint8_t * getCursor ()
 Get an internal pointer to the current location in the DataOutput byte array. More...
 
uint32_t getRemainingBufferLength () const
 Get a pointer to the internal buffer of DataOutput. More...
 
void reset ()
 Reset the internal cursor to the start of the buffer. More...
 
void rewindCursor (uint32_t offset)
 Rewind the buffer cursor by the given offset. More...
 
void write (uint8_t value)
 Write an unsigned byte to the DataOutput. More...
 
void write (int8_t value)
 Write a signed byte to the DataOutput. More...
 
void writeArrayLen (int32_t len)
 Write a 32-bit signed integer array length value to the DataOutput in a manner compatible with java server's DataSerializer.writeArrayLength. More...
 
void writeASCII (const char *value, uint32_t length=0)
 Writes the given ASCII string supporting maximum length of 64K (i.e. More...
 
void writeASCIIHuge (const char *value, uint32_t length=0)
 Writes the given ASCII string supporting upto maximum 32-bit integer value. More...
 
void writeBoolean (bool value)
 Write a boolean value to the DataOutput. More...
 
void writeBytes (const uint8_t *bytes, int32_t len)
 Write an array of unsigned bytes to the DataOutput. More...
 
void writeBytes (const int8_t *bytes, int32_t len)
 Write an array of signed bytes to the DataOutput. More...
 
void writeBytesOnly (const uint8_t *bytes, uint32_t len)
 Write an array of unsigned bytes without its length to the DataOutput. More...
 
void writeBytesOnly (const int8_t *bytes, uint32_t len)
 Write an array of signed bytes without its length to the DataOutput. More...
 
void writeChar (uint16_t value)
 Write a 16-bit Char (wchar_t) value to the DataOutput. More...
 
void writeDouble (double value)
 Write a double precision real number to the DataOutput. More...
 
void writeFloat (float value)
 Write a float value to the DataOutput. More...
 
void writeFullUTF (const char *value, uint32_t length=0)
 Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of 64K (i.e. More...
 
void writeInt (uint16_t value)
 Write a 16-bit unsigned integer value to the DataOutput. More...
 
void writeInt (uint32_t value)
 Write a 32-bit unsigned integer value to the DataOutput. More...
 
void writeInt (uint64_t value)
 Write a 64-bit unsigned integer value to the DataOutput. More...
 
void writeInt (int16_t value)
 Write a 16-bit signed integer value to the DataOutput. More...
 
void writeInt (int32_t value)
 Write a 32-bit signed integer value to the DataOutput. More...
 
void writeInt (int64_t value)
 Write a 64-bit signed integer value to the DataOutput. More...
 
template<class PTR >
void writeObject (const SharedPtr< PTR > &objptr, bool isDelta=false)
 Write a Serializable object to the DataOutput. More...
 
void writeObject (const Serializable *objptr)
 Write a Serializable object to the DataOutput. More...
 
void writeUTF (const char *value, uint32_t length=0)
 Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of 64K (i.e. More...
 
void writeUTF (const wchar_t *value, uint32_t length=0)
 Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of 64K (i.e. More...
 
void writeUTFHuge (const char *value, uint32_t length=0)
 Writes the given string using java modified UTF-8 encoding. More...
 
void writeUTFHuge (const wchar_t *value, uint32_t length=0)
 Writes the given string using java modified UTF-8 encoding. More...
 
 ~DataOutput ()
 Destruct a DataOutput, including releasing the created buffer. More...
 

Static Public Member Functions

static int32_t getEncodedLength (const char *value, int32_t length=0, uint32_t *valLength=NULL)
 Get the length required to represent a given wide-character string in java modified UTF-8 format. More...
 
static int32_t getEncodedLength (const wchar_t *value, int32_t length=0, uint32_t *valLength=NULL)
 Get the length required to represent a given wide-character string in java modified UTF-8 format. More...
 

Detailed Description

Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a byte stream.

This class is intentionally not thread safe.

Constructor & Destructor Documentation

apache::geode::client::DataOutput::DataOutput ( )

Construct a new DataOutput.

apache::geode::client::DataOutput::~DataOutput ( )
inline

Destruct a DataOutput, including releasing the created buffer.

Member Function Documentation

void apache::geode::client::DataOutput::advanceCursor ( uint32_t  offset)
inline

Advance the buffer cursor by the given offset.

Parameters
offsetthe offset by which to advance the cursor
const uint8_t* apache::geode::client::DataOutput::getBuffer ( ) const
inline

Get a pointer to the internal buffer of DataOutput.

const uint8_t* apache::geode::client::DataOutput::getBuffer ( uint32_t *  rsize) const
inline

Get a pointer to the internal buffer of DataOutput.

Parameters
rsizethe size of buffer is filled in this output parameter; should not be NULL
uint32_t apache::geode::client::DataOutput::getBufferLength ( ) const
inline

Get the length of current data in the internal buffer of DataOutput.

const uint8_t* apache::geode::client::DataOutput::getCursor ( )
inline

Get an internal pointer to the current location in the DataOutput byte array.

static int32_t apache::geode::client::DataOutput::getEncodedLength ( const char *  value,
int32_t  length = 0,
uint32_t *  valLength = NULL 
)
inlinestatic

Get the length required to represent a given wide-character string in java modified UTF-8 format.

Parameters
valueThe C string.
lengthThe length of the string; or zero to use the full string.
Returns
The length required for representation in java modified UTF-8 format.
See also
DataInput::getDecodedLength
static int32_t apache::geode::client::DataOutput::getEncodedLength ( const wchar_t *  value,
int32_t  length = 0,
uint32_t *  valLength = NULL 
)
inlinestatic

Get the length required to represent a given wide-character string in java modified UTF-8 format.

Parameters
valueThe wide-character string.
lengthThe length of the string.
Returns
The length required for representation in java modified UTF-8 format.
See also
DataInput::getDecodedLength
uint32_t apache::geode::client::DataOutput::getRemainingBufferLength ( ) const
inline

Get a pointer to the internal buffer of DataOutput.

void apache::geode::client::DataOutput::reset ( )
inline

Reset the internal cursor to the start of the buffer.

void apache::geode::client::DataOutput::rewindCursor ( uint32_t  offset)
inline

Rewind the buffer cursor by the given offset.

Parameters
offsetthe offset by which to rewind the cursor
void apache::geode::client::DataOutput::write ( uint8_t  value)
inline

Write an unsigned byte to the DataOutput.

Parameters
valuethe unsigned byte to be written
void apache::geode::client::DataOutput::write ( int8_t  value)
inline

Write a signed byte to the DataOutput.

Parameters
valuethe signed byte to be written
void apache::geode::client::DataOutput::writeArrayLen ( int32_t  len)
inline

Write a 32-bit signed integer array length value to the DataOutput in a manner compatible with java server's DataSerializer.writeArrayLength.

Parameters
valuethe 32-bit signed integer array length to be written
void apache::geode::client::DataOutput::writeASCII ( const char *  value,
uint32_t  length = 0 
)
inline

Writes the given ASCII string supporting maximum length of 64K (i.e.

unsigned 16-bit integer).

Remarks
The string will be truncated if greater than the maximum permissible length of 64K. Use writeBytes or writeASCIIHuge to write ASCII strings of length larger than this.
Parameters
valuethe C string to be written
lengththe number of characters from start of string to be written; the default value of 0 implies the complete string
void apache::geode::client::DataOutput::writeASCIIHuge ( const char *  value,
uint32_t  length = 0 
)
inline

Writes the given ASCII string supporting upto maximum 32-bit integer value.

Remarks
Use this to write large ASCII strings. The other writeASCII method will truncate strings greater than 64K in size.
Parameters
valuethe wide-character string to be written
lengththe number of characters from start of string to be written; the default value of 0 implies the complete string
void apache::geode::client::DataOutput::writeBoolean ( bool  value)
inline

Write a boolean value to the DataOutput.

Parameters
valuethe boolean value to be written
void apache::geode::client::DataOutput::writeBytes ( const uint8_t *  bytes,
int32_t  len 
)
inline

Write an array of unsigned bytes to the DataOutput.

Parameters
valuethe array of unsigned bytes to be written
lenthe number of bytes from the start of array to be written
void apache::geode::client::DataOutput::writeBytes ( const int8_t *  bytes,
int32_t  len 
)
inline

Write an array of signed bytes to the DataOutput.

Parameters
valuethe array of signed bytes to be written
lenthe number of bytes from the start of array to be written
void apache::geode::client::DataOutput::writeBytesOnly ( const uint8_t *  bytes,
uint32_t  len 
)
inline

Write an array of unsigned bytes without its length to the DataOutput.

Remarks
The difference between this and writeBytes is that this does write the length of bytes so the corresponding DataInput::readBytesOnly (unlike DataInput::readBytes) needs the length argument explicitly.
Parameters
valuethe array of unsigned bytes to be written
lenthe number of bytes from the start of array to be written
void apache::geode::client::DataOutput::writeBytesOnly ( const int8_t *  bytes,
uint32_t  len 
)
inline

Write an array of signed bytes without its length to the DataOutput.

Remarks
The difference between this and writeBytes is that this does write the length of bytes so the corresponding DataInput::readBytesOnly (unlike DataInput::readBytes) needs the length argument explicitly.
Parameters
valuethe array of signed bytes to be written
lenthe number of bytes from the start of array to be written
void apache::geode::client::DataOutput::writeChar ( uint16_t  value)
inline

Write a 16-bit Char (wchar_t) value to the DataOutput.

Parameters
valuethe 16-bit wchar_t value to be written
void apache::geode::client::DataOutput::writeDouble ( double  value)
inline

Write a double precision real number to the DataOutput.

Parameters
valuethe double precision real number to be written
void apache::geode::client::DataOutput::writeFloat ( float  value)
inline

Write a float value to the DataOutput.

Parameters
valuethe float value to be written
void apache::geode::client::DataOutput::writeFullUTF ( const char *  value,
uint32_t  length = 0 
)
inline

Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of 64K (i.e.

unsigned 16-bit integer).

Remarks
The string will be truncated if greater than the maximum permissible length of 64K. Use writeUTFHuge to write strings of length larger than this.
Parameters
valuethe C string to be written
void apache::geode::client::DataOutput::writeInt ( uint16_t  value)
inline

Write a 16-bit unsigned integer value to the DataOutput.

Parameters
valuethe 16-bit unsigned integer value to be written
void apache::geode::client::DataOutput::writeInt ( uint32_t  value)
inline

Write a 32-bit unsigned integer value to the DataOutput.

Parameters
valuethe 32-bit unsigned integer value to be written
void apache::geode::client::DataOutput::writeInt ( uint64_t  value)
inline

Write a 64-bit unsigned integer value to the DataOutput.

Parameters
valuethe 64-bit unsigned integer value to be written
void apache::geode::client::DataOutput::writeInt ( int16_t  value)
inline

Write a 16-bit signed integer value to the DataOutput.

Parameters
valuethe 16-bit signed integer value to be written
void apache::geode::client::DataOutput::writeInt ( int32_t  value)
inline

Write a 32-bit signed integer value to the DataOutput.

Parameters
valuethe 32-bit signed integer value to be written
void apache::geode::client::DataOutput::writeInt ( int64_t  value)
inline

Write a 64-bit signed integer value to the DataOutput.

Parameters
valuethe 64-bit signed integer value to be written
template<class PTR >
void apache::geode::client::DataOutput::writeObject ( const SharedPtr< PTR > &  objptr,
bool  isDelta = false 
)
inline

Write a Serializable object to the DataOutput.

Parameters
objptrsmart pointer to the Serializable object to be written
void apache::geode::client::DataOutput::writeObject ( const Serializable objptr)
inline

Write a Serializable object to the DataOutput.

Parameters
objptrpointer to the Serializable object to be written
void apache::geode::client::DataOutput::writeUTF ( const char *  value,
uint32_t  length = 0 
)
inline

Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of 64K (i.e.

unsigned 16-bit integer).

Remarks
The string will be truncated if greater than the maximum permissible length of 64K. Use writeUTFHuge to write strings of length larger than this.
Parameters
valuethe C string to be written
lengththe number of characters from start of string to be written; the default value of 0 implies the complete string
void apache::geode::client::DataOutput::writeUTF ( const wchar_t *  value,
uint32_t  length = 0 
)
inline

Writes the given given string using java modified UTF-8 encoding supporting maximum encoded length of 64K (i.e.

unsigned 16-bit integer).

Remarks
The string will be truncated if greater than the maximum permissible length of 64K. Use writeUTFHuge to write strings of length larger than this.
Parameters
valuethe wide-character string to be written
lengththe number of characters from start of string to be written; the default value of 0 implies the complete string
void apache::geode::client::DataOutput::writeUTFHuge ( const char *  value,
uint32_t  length = 0 
)
inline

Writes the given string using java modified UTF-8 encoding.

Remarks
Use this to write large strings. The other writeUTF method will truncate strings greater than 64K in size.
Parameters
valuethe C string to be written
lengththe number of characters from start of string to be written; the default value of 0 implies the complete string assuming a null terminated string; do not use this unless sure that the UTF string does not contain any null characters
void apache::geode::client::DataOutput::writeUTFHuge ( const wchar_t *  value,
uint32_t  length = 0 
)
inline

Writes the given string using java modified UTF-8 encoding.

Remarks
Use this to write large strings. The other writeUTF method will truncate strings greater than 64K in size.
Parameters
valuethe wide-character string to be written
lengththe number of characters from start of string to be written; the default value of 0 implies the complete string

Pivotal GemFire C++ Cache API Documentation