PVData C++  8.0.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
epics::pvData::ByteBuffer Class Reference

This class implements a Bytebuffer that is like the java.nio.ByteBuffer. More...

#include <misc/pv/byteBuffer.h>

Public Member Functions

 ByteBuffer (std::size_t size, int byteOrder=EPICS_BYTE_ORDER)
 
 ByteBuffer (char *buffer, std::size_t size, int byteOrder=EPICS_BYTE_ORDER)
 
 ~ByteBuffer ()
 
void setEndianess (int byteOrder)
 
const char * getBuffer () const
 
void clear ()
 
void flip ()
 
void rewind ()
 
std::size_t getPosition () const
 
void setPosition (std::size_t pos)
 
std::size_t getLimit () const
 
void setLimit (std::size_t limit)
 
std::size_t getRemaining () const
 
std::size_t getSize () const
 
template<typename T >
void put (T value)
 
template<typename T >
void put (std::size_t index, T value) const
 
template<typename T >
get ()
 
template<typename T >
get (std::size_t index) const
 
void put (const char *src, std::size_t src_offset, std::size_t count)
 
void get (char *dest, std::size_t dest_offset, std::size_t count)
 
template<typename T >
void putArray (const T *values, std::size_t count)
 
template<typename T >
void getArray (T *values, std::size_t count)
 
template<typename T >
bool reverse () const
 
void putBoolean (bool value)
 
void putByte (int8 value)
 
void putShort (int16 value)
 
void putInt (int32 value)
 
void putLong (int64 value)
 
void putFloat (float value)
 
void putDouble (double value)
 
void putBoolean (std::size_t index, bool value)
 
void putByte (std::size_t index, int8 value)
 
void putShort (std::size_t index, int16 value)
 
void putInt (std::size_t index, int32 value)
 
void putLong (std::size_t index, int64 value)
 
void putFloat (std::size_t index, float value)
 
void putDouble (std::size_t index, double value)
 
bool getBoolean ()
 
int8 getByte ()
 
int16 getShort ()
 
int32 getInt ()
 
int64 getLong ()
 
float getFloat ()
 
double getDouble ()
 
bool getBoolean (std::size_t index)
 
int8 getByte (std::size_t index)
 
int16 getShort (std::size_t index)
 
int32 getInt (std::size_t index)
 
int64 getLong (std::size_t index)
 
float getFloat (std::size_t index)
 
double getDouble (std::size_t index)
 
const char * getArray () const
 
template<>
bool reverse () const
 
template<>
bool reverse () const
 
template<>
bool reverse () const
 
template<>
bool reverse () const
 
template<>
bool reverse () const
 

Detailed Description

This class implements a Bytebuffer that is like the java.nio.ByteBuffer.

A BitSet is not safe for multithreaded use without external synchronization.

Based on Java implementation.

Definition at line 236 of file byteBuffer.h.

Constructor & Destructor Documentation

epics::pvData::ByteBuffer::ByteBuffer ( std::size_t  size,
int  byteOrder = EPICS_BYTE_ORDER 
)
inline

Constructor.

Parameters
sizeThe number of bytes.
byteOrderThe byte order. Must be one of EPICS_BYTE_ORDER,EPICS_ENDIAN_LITTLE,EPICS_ENDIAN_BIG.

Definition at line 246 of file byteBuffer.h.

epics::pvData::ByteBuffer::ByteBuffer ( char *  buffer,
std::size_t  size,
int  byteOrder = EPICS_BYTE_ORDER 
)
inline

Constructor for wrapping an existing buffer. Given buffer will not be released by the ByteBuffer instance.

Parameters
bufferExisting buffer. May not be NULL.
sizeThe number of bytes.
byteOrderThe byte order. Must be one of EPICS_BYTE_ORDER,EPICS_ENDIAN_LITTLE,EPICS_ENDIAN_BIG.

Definition at line 265 of file byteBuffer.h.

epics::pvData::ByteBuffer::~ByteBuffer ( )
inline

Destructor

Definition at line 278 of file byteBuffer.h.

Member Function Documentation

void epics::pvData::ByteBuffer::clear ( )
inline

Makes a buffer ready for a new sequence of channel-read or relative put operations: It sets the limit to the capacity and the position to zero.

Definition at line 305 of file byteBuffer.h.

void epics::pvData::ByteBuffer::flip ( )
inline

Makes a buffer ready to read out previously written values.

Typically _limit==_buffer+_size is the initial state, but this is not required.

V _buffer V _position V _limit V _buffer+_size |_______written_______|____uninitialized___|____allocated___|

becomes

V _buffer/_position V _limit V _buffer+size |_______written_______|________________allocated____________|

Definition at line 324 of file byteBuffer.h.

template<typename T >
T epics::pvData::ByteBuffer::get ( )
inline

Get the new object from the byte buffer. The item MUST have type T. The position is adjusted based on the type.

Returns
The object.

Definition at line 761 of file byteBuffer.h.

template<typename T >
T epics::pvData::ByteBuffer::get ( std::size_t  index) const
inline

Get the new object from the byte buffer at the specified index. The item MUST have type T. The position is adjusted based on the type.

Parameters
indexThe location in the byte buffer.
Returns
The object.

Definition at line 775 of file byteBuffer.h.

void epics::pvData::ByteBuffer::get ( char *  dest,
std::size_t  dest_offset,
std::size_t  count 
)
inline

Get a sub-array of bytes from the byte buffer. The position is increased by the count.

Parameters
destThe destination array.
dest_offsetThe starting position within src.
countThe number of bytes to put into the byte buffer. Must be less than getRemaining()

Definition at line 468 of file byteBuffer.h.

template<typename T >
void epics::pvData::ByteBuffer::getArray ( T *  values,
std::size_t  count 
)
inline

Get an array of type T from the byte buffer. The position is adjusted.

Parameters
valuesThe destination array.
countThe number of elements.

Definition at line 803 of file byteBuffer.h.

bool epics::pvData::ByteBuffer::getBoolean ( )
inline

Get a boolean value from the byte buffer.

Returns
The value.

Definition at line 597 of file byteBuffer.h.

bool epics::pvData::ByteBuffer::getBoolean ( std::size_t  index)
inline

Get a boolean value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 640 of file byteBuffer.h.

const char* epics::pvData::ByteBuffer::getBuffer ( ) const
inline

Get the raw buffer data.

Returns
the raw buffer data.

Definition at line 297 of file byteBuffer.h.

int8 epics::pvData::ByteBuffer::getByte ( )
inline

Get a byte value from the byte buffer.

Returns
The value.

Definition at line 603 of file byteBuffer.h.

int8 epics::pvData::ByteBuffer::getByte ( std::size_t  index)
inline

Get a byte value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 647 of file byteBuffer.h.

double epics::pvData::ByteBuffer::getDouble ( )
inline

Get a double value from the byte buffer.

Returns
The value.

Definition at line 633 of file byteBuffer.h.

double epics::pvData::ByteBuffer::getDouble ( std::size_t  index)
inline

Get a boolean value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 682 of file byteBuffer.h.

float epics::pvData::ByteBuffer::getFloat ( )
inline

Get a float value from the byte buffer.

Returns
The value.

Definition at line 627 of file byteBuffer.h.

float epics::pvData::ByteBuffer::getFloat ( std::size_t  index)
inline

Get a float value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 675 of file byteBuffer.h.

int32 epics::pvData::ByteBuffer::getInt ( )
inline

Get a int value from the byte buffer.

Returns
The value.

Definition at line 615 of file byteBuffer.h.

int32 epics::pvData::ByteBuffer::getInt ( std::size_t  index)
inline

Get an int value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 661 of file byteBuffer.h.

std::size_t epics::pvData::ByteBuffer::getLimit ( ) const
inline

Returns this buffer's limit.

Returns
The offset into the raw buffer.

Definition at line 371 of file byteBuffer.h.

int64 epics::pvData::ByteBuffer::getLong ( )
inline

Get a long value from the byte buffer.

Returns
The value.

Definition at line 621 of file byteBuffer.h.

int64 epics::pvData::ByteBuffer::getLong ( std::size_t  index)
inline

Get a long value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 668 of file byteBuffer.h.

std::size_t epics::pvData::ByteBuffer::getPosition ( ) const
inline

Returns the current position.

Returns
The current position in the raw data.

Definition at line 349 of file byteBuffer.h.

std::size_t epics::pvData::ByteBuffer::getRemaining ( ) const
inline

Returns the number of elements between the current position and the limit.

Returns
The number of elements remaining in this buffer.

Definition at line 394 of file byteBuffer.h.

int16 epics::pvData::ByteBuffer::getShort ( )
inline

Get a short value from the byte buffer.

Returns
The value.

Definition at line 609 of file byteBuffer.h.

int16 epics::pvData::ByteBuffer::getShort ( std::size_t  index)
inline

Get a short value from the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer.
Returns
The value.

Definition at line 654 of file byteBuffer.h.

std::size_t epics::pvData::ByteBuffer::getSize ( ) const
inline

Returns The size, i.e. capacity of the raw data buffer in bytes.

Returns
The size of the raw data buffer.

Definition at line 403 of file byteBuffer.h.

template<typename T >
void epics::pvData::ByteBuffer::put ( value)
inline

Put the value into the raw buffer as a byte stream in the current byte order.

Parameters
valueThe value to be put into the byte buffer.

Definition at line 734 of file byteBuffer.h.

template<typename T >
void epics::pvData::ByteBuffer::put ( std::size_t  index,
value 
) const
inline

Put the value into the raw buffer at the specified index as a byte stream in the current byte order.

Parameters
indexOffset in the byte buffer.
valueThe value to be put into the byte buffer.

Definition at line 746 of file byteBuffer.h.

void epics::pvData::ByteBuffer::put ( const char *  src,
std::size_t  src_offset,
std::size_t  count 
)
inline

Put a sub-array of bytes into the byte buffer. The position is increased by the count.

Parameters
srcThe source array.
src_offsetThe starting position within src.
countThe number of bytes to put into the byte buffer. Must be less than getRemaining()

Definition at line 454 of file byteBuffer.h.

template<typename T >
void epics::pvData::ByteBuffer::putArray ( const T *  values,
std::size_t  count 
)
inline

Put an array of type T into the byte buffer. The position is adjusted.

Parameters
valuesThe input array.
countThe number of elements.

Definition at line 787 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putBoolean ( bool  value)
inline

Put a boolean value into the byte buffer.

Parameters
valueThe value.

Definition at line 505 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putBoolean ( std::size_t  index,
bool  value 
)
inline

Put a boolean value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 549 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putByte ( int8  value)
inline

Put a byte value into the byte buffer.

Parameters
valueThe value.

Definition at line 511 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putByte ( std::size_t  index,
int8  value 
)
inline

Put a byte value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 556 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putDouble ( double  value)
inline

Put a double value into the byte buffer.

Parameters
valueThe value.

Definition at line 541 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putDouble ( std::size_t  index,
double  value 
)
inline

Put a double value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 591 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putFloat ( float  value)
inline

Put a float value into the byte buffer.

Parameters
valueThe value.

Definition at line 535 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putFloat ( std::size_t  index,
float  value 
)
inline

Put a float value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 584 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putInt ( int32  value)
inline

Put an int value into the byte buffer.

Parameters
valueThe value.

Definition at line 523 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putInt ( std::size_t  index,
int32  value 
)
inline

Put an int value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 570 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putLong ( int64  value)
inline

Put a long value into the byte buffer.

Parameters
valueThe value.

Definition at line 529 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putLong ( std::size_t  index,
int64  value 
)
inline

Put a long value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 577 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putShort ( int16  value)
inline

Put a short value into the byte buffer.

Parameters
valueThe value.

Definition at line 517 of file byteBuffer.h.

void epics::pvData::ByteBuffer::putShort ( std::size_t  index,
int16  value 
)
inline

Put a short value into the byte buffer at the specified index.

Parameters
indexThe offset in the byte buffer,
valueThe value.

Definition at line 563 of file byteBuffer.h.

template<typename T >
bool epics::pvData::ByteBuffer::reverse ( ) const
inline

Is the byte order the EPICS_BYTE_ORDER

Returns
(false,true) if (is, is not) the EPICS_BYTE_ORDER

Definition at line 496 of file byteBuffer.h.

void epics::pvData::ByteBuffer::rewind ( )
inline

Makes a buffer ready for re-reading the data that it already contains: It leaves the limit unchanged and sets the position to zero.

Note that this may allow reading of uninitialized values. flip() should be considered

V _buffer V _position V _limit V _buffer+_size |_______written_______|____uninitialized___|____allocated___|

becomes

V _buffer/_position V _limit V _buffer+size |_______written_______|____uninitialized___|____allocated___|

Definition at line 342 of file byteBuffer.h.

void epics::pvData::ByteBuffer::setEndianess ( int  byteOrder)
inline

Set the byte order.

Parameters
byteOrderThe byte order. Must be one of EPICS_BYTE_ORDER,EPICS_ENDIAN_LITTLE,EPICS_ENDIAN_BIG,

Definition at line 288 of file byteBuffer.h.

void epics::pvData::ByteBuffer::setLimit ( std::size_t  limit)
inline

Sets this buffer's limit. If the position is larger than the new limit then it is set to the new limit.s If the mark is defined and larger than the new limit then it is discarded.

Parameters
limitThe new position value; must be no larger than the current limit

Definition at line 383 of file byteBuffer.h.

void epics::pvData::ByteBuffer::setPosition ( std::size_t  pos)
inline

Sets the buffer position. If the mark is defined and larger than the new position then it is discarded.

Parameters
posThe offset into the raw buffer. The new position value; must be no larger than the current limit

Definition at line 360 of file byteBuffer.h.


The documentation for this class was generated from the following file: