VMware Tanzu GemFire Native C++ Reference 10.3.0
apache::geode::client::DataInput Class Reference

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

#include <DataInput.hpp>

Public Member Functions

void advanceCursor (size_t offset)
 advance the cursor by given offset More...
 
const uint8_t * currentBufferPosition () const
 Get the pointer to current buffer position. More...
 
size_t getBytesRead () const
 get the number of bytes read in the buffer More...
 
size_t getBytesRemaining () const
 get the number of bytes remaining to be read in the buffer More...
 
int8_t read ()
 Read a signed byte from the DataInput. More...
 
int32_t readArrayLength ()
 Read a 32-bit signed integer array length value from the DataInput in a manner compatible with java server's DataSerializer.readArrayLength. More...
 
bool readBoolean ()
 Read a boolean value from the DataInput. More...
 
void readBytes (int8_t **bytes, int32_t *len)
 Read an array of signed bytes from the DataInput expecting to find the length of array in the stream at the start. More...
 
void readBytes (uint8_t **bytes, int32_t *len)
 Read an array of unsigned bytes from the DataInput expecting to find the length of array in the stream at the start. More...
 
void readBytesOnly (int8_t *buffer, size_t len)
 Read the given number of signed bytes from the DataInput. More...
 
void readBytesOnly (uint8_t *buffer, size_t len)
 Read the given number of unsigned bytes from the DataInput. More...
 
double readDouble ()
 Read a double precision number from the DataInput. More...
 
float readFloat ()
 Read a float from the DataInput. More...
 
int16_t readInt16 ()
 Read a 16-bit signed integer from the DataInput. More...
 
int32_t readInt32 ()
 Read a 32-bit signed integer from the DataInput.g. More...
 
int64_t readInt64 ()
 Read a 64-bit signed integer from the DataInput. More...
 
std::shared_ptr< SerializablereadObject ()
 Read a Serializable object from the DataInput. More...
 
void readObject (std::shared_ptr< Serializable > &ptr)
 Read a Serializable object from the DataInput. More...
 
int64_t readUnsignedVL ()
 Decode a 64 bit integer as a variable length array. More...
 
void reset ()
 reset the cursor to the start of buffer More...
 
void rewindCursor (size_t offset)
 rewind the cursor by given offset More...
 

Protected Member Functions

 DataInput (const uint8_t *buffer, size_t len, const CacheImpl *cache, Pool *pool)
 constructor given a pre-allocated byte array with size More...
 

Detailed Description

Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from a byte stream.

This class is intentionally not thread safe.

Remarks
None of the output parameters in the methods below can be nullptr unless otherwise noted.

Constructor & Destructor Documentation

◆ DataInput()

apache::geode::client::DataInput::DataInput ( const uint8_t *  buffer,
size_t  len,
const CacheImpl *  cache,
Pool pool 
)
protected

constructor given a pre-allocated byte array with size

Member Function Documentation

◆ advanceCursor()

void apache::geode::client::DataInput::advanceCursor ( size_t  offset)
inline

advance the cursor by given offset

◆ currentBufferPosition()

const uint8_t * apache::geode::client::DataInput::currentBufferPosition ( ) const
inline

Get the pointer to current buffer position.

This should be treated as readonly and modification of contents using this internal pointer has undefined behavior.

◆ getBytesRead()

size_t apache::geode::client::DataInput::getBytesRead ( ) const
inline

get the number of bytes read in the buffer

◆ getBytesRemaining()

size_t apache::geode::client::DataInput::getBytesRemaining ( ) const
inline

get the number of bytes remaining to be read in the buffer

◆ read()

int8_t apache::geode::client::DataInput::read ( )
inline

Read a signed byte from the DataInput.

@return signed byte read from stream

◆ readArrayLength()

int32_t apache::geode::client::DataInput::readArrayLength ( )
inline

Read a 32-bit signed integer array length value from the DataInput in a manner compatible with java server's DataSerializer.readArrayLength.

◆ readBoolean()

bool apache::geode::client::DataInput::readBoolean ( )
inline

Read a boolean value from the DataInput.

◆ readBytes() [1/2]

void apache::geode::client::DataInput::readBytes ( int8_t **  bytes,
int32_t *  len 
)
inline

Read an array of signed bytes from the DataInput expecting to find the length of array in the stream at the start.

Remarks
This method is complimentary to DataOutput::writeBytes.
Parameters
bytesoutput array to hold the bytes read from stream; the array is allocated by this method
lenoutput parameter to hold the length of array read from stream

◆ readBytes() [2/2]

void apache::geode::client::DataInput::readBytes ( uint8_t **  bytes,
int32_t *  len 
)
inline

Read an array of unsigned bytes from the DataInput expecting to find the length of array in the stream at the start.

Remarks
This method is complimentary to DataOutput::writeBytes.
Parameters
bytesoutput array to hold the bytes read from stream; the array is allocated by this method
lenoutput parameter to hold the length of array read from stream

◆ readBytesOnly() [1/2]

void apache::geode::client::DataInput::readBytesOnly ( int8_t *  buffer,
size_t  len 
)
inline

Read the given number of signed bytes from the DataInput.

Remarks
This method is complimentary to DataOutput::writeBytesOnly and, unlike readBytes, does not expect the length of array in the stream.
Parameters
bufferarray to hold the bytes read from stream
lennumber of signed bytes to be read

◆ readBytesOnly() [2/2]

void apache::geode::client::DataInput::readBytesOnly ( uint8_t *  buffer,
size_t  len 
)
inline

Read the given number of unsigned bytes from the DataInput.

Remarks
This method is complimentary to DataOutput::writeBytesOnly and, unlike readBytes, does not expect the length of array in the stream.
Parameters
bufferarray to hold the bytes read from stream
lennumber of unsigned bytes to be read

◆ readDouble()

double apache::geode::client::DataInput::readDouble ( )
inline

Read a double precision number from the DataInput.

◆ readFloat()

float apache::geode::client::DataInput::readFloat ( )
inline

Read a float from the DataInput.

◆ readInt16()

int16_t apache::geode::client::DataInput::readInt16 ( )
inline

Read a 16-bit signed integer from the DataInput.

Returns
16-bit signed integer read from stream

◆ readInt32()

int32_t apache::geode::client::DataInput::readInt32 ( )
inline

Read a 32-bit signed integer from the DataInput.g.

◆ readInt64()

int64_t apache::geode::client::DataInput::readInt64 ( )
inline

Read a 64-bit signed integer from the DataInput.

◆ readObject() [1/2]

std::shared_ptr< Serializable > apache::geode::client::DataInput::readObject ( )
inline

Read a Serializable object from the DataInput.

Returns
Serializable object or nullptr.

◆ readObject() [2/2]

void apache::geode::client::DataInput::readObject ( std::shared_ptr< Serializable > &  ptr)
inline

Read a Serializable object from the DataInput.

Null objects are handled.

◆ readUnsignedVL()

int64_t apache::geode::client::DataInput::readUnsignedVL ( )
inline

Decode a 64 bit integer as a variable length array.

This is taken from the varint encoding in protobufs (BSD licensed). See https://developers.google.com/protocol-buffers/docs/encoding

◆ reset()

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

reset the cursor to the start of buffer

◆ rewindCursor()

void apache::geode::client::DataInput::rewindCursor ( size_t  offset)
inline

rewind the cursor by given offset


Apache Geode C++ Cache API Documentation