This is Unofficial EPICS BASE Doxygen Site
epics::pvData::ByteBuffer Class Reference

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

#include "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
 
EPICS_ALWAYS_INLINE 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 >
EPICS_ALWAYS_INLINE bool reverse () const
 
void align (std::size_t size, char fill='\0')
 
EPICS_ALWAYS_INLINE void putBoolean (bool value)
 
EPICS_ALWAYS_INLINE void putByte (int8 value)
 
EPICS_ALWAYS_INLINE void putShort (int16 value)
 
EPICS_ALWAYS_INLINE void putInt (int32 value)
 
EPICS_ALWAYS_INLINE void putLong (int64 value)
 
EPICS_ALWAYS_INLINE void putFloat (float value)
 
EPICS_ALWAYS_INLINE void putDouble (double value)
 
EPICS_ALWAYS_INLINE void putBoolean (std::size_t index, bool value)
 
EPICS_ALWAYS_INLINE void putByte (std::size_t index, int8 value)
 
EPICS_ALWAYS_INLINE void putShort (std::size_t index, int16 value)
 
EPICS_ALWAYS_INLINE void putInt (std::size_t index, int32 value)
 
EPICS_ALWAYS_INLINE void putLong (std::size_t index, int64 value)
 
EPICS_ALWAYS_INLINE void putFloat (std::size_t index, float value)
 
EPICS_ALWAYS_INLINE void putDouble (std::size_t index, double value)
 
EPICS_ALWAYS_INLINE bool getBoolean ()
 
EPICS_ALWAYS_INLINE int8 getByte ()
 
EPICS_ALWAYS_INLINE int16 getShort ()
 
EPICS_ALWAYS_INLINE int32 getInt ()
 
EPICS_ALWAYS_INLINE int64 getLong ()
 
EPICS_ALWAYS_INLINE float getFloat ()
 
EPICS_ALWAYS_INLINE double getDouble ()
 
EPICS_ALWAYS_INLINE bool getBoolean (std::size_t index)
 
EPICS_ALWAYS_INLINE int8 getByte (std::size_t index)
 
EPICS_ALWAYS_INLINE int16 getShort (std::size_t index)
 
EPICS_ALWAYS_INLINE int32 getInt (std::size_t index)
 
EPICS_ALWAYS_INLINE int64 getLong (std::size_t index)
 
EPICS_ALWAYS_INLINE float getFloat (std::size_t index)
 
EPICS_ALWAYS_INLINE double getDouble (std::size_t index)
 
EPICS_ALWAYS_INLINE const char * getArray () const EPICS_DEPRECATED
 
template<>
EPICS_ALWAYS_INLINE bool reverse () const
 
template<>
EPICS_ALWAYS_INLINE bool reverse () const
 
template<>
EPICS_ALWAYS_INLINE bool reverse () const
 
template<>
EPICS_ALWAYS_INLINE bool reverse () const
 
template<>
EPICS_ALWAYS_INLINE 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 233 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 243 of file byteBuffer.h.

243  :
244  _buffer((char*)std::malloc(size)), _size(size),
245  _reverseEndianess(byteOrder != EPICS_BYTE_ORDER),
246  _reverseFloatEndianess(byteOrder != EPICS_FLOAT_WORD_ORDER),
247  _wrapped(false)
248  {
249  if(!_buffer)
250  throw std::bad_alloc();
251  clear();
252  }
#define EPICS_FLOAT_WORD_ORDER
Definition: osdWireConfig.h:60
#define EPICS_BYTE_ORDER
Definition: osdWireConfig.h:16
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 262 of file byteBuffer.h.

262  :
263  _buffer(buffer), _size(size),
264  _reverseEndianess(byteOrder != EPICS_BYTE_ORDER),
265  _reverseFloatEndianess(byteOrder != EPICS_FLOAT_WORD_ORDER),
266  _wrapped(true)
267  {
268  if(!_buffer)
269  throw std::invalid_argument("ByteBuffer can't be constructed with NULL");
270  clear();
271  }
#define EPICS_FLOAT_WORD_ORDER
Definition: osdWireConfig.h:60
#define EPICS_BYTE_ORDER
Definition: osdWireConfig.h:16
epics::pvData::ByteBuffer::~ByteBuffer ( )
inline

Destructor

Definition at line 275 of file byteBuffer.h.

276  {
277  if (_buffer && !_wrapped) std::free(_buffer);
278  }

Member Function Documentation

void epics::pvData::ByteBuffer::align ( std::size_t  size,
char  fill = '\0' 
)
inline

Adjust position to the next multiple of 'size.

Parameters
sizeThe alignment requirement, must be a power of 2. (unchecked)
fillvalue to use for padding bytes (default '\0').
Note
This alignment is absolute, not necessarily with respect to _buffer.

Definition at line 504 of file byteBuffer.h.

505  {
506  const std::size_t k = size - 1, bufidx = (std::size_t)_position;
507  if(bufidx&k) {
508  std::size_t npad = size-(bufidx&k);
509  assert(npad<=getRemaining());
510  std::fill(_position, _position+npad, fill);
511  _position += npad;
512  }
513  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
std::size_t getRemaining() const
Definition: byteBuffer.h:391
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 302 of file byteBuffer.h.

303  {
304  _position = _buffer;
305  _limit = _buffer + _size;
306  }
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 321 of file byteBuffer.h.

321  {
322  _limit = _position;
323  _position = _buffer;
324  }
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 775 of file byteBuffer.h.

777  {
778  assert(sizeof(T)<=getRemaining());
779 
780  T value = detail::load_unaligned<T>(_position);
781  _position += sizeof(T);
782 
783  if(reverse<T>())
784  value = swap<T>(value);
785  return value;
786  }
Definition: link.h:174
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
std::size_t getRemaining() const
Definition: byteBuffer.h:391
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 789 of file byteBuffer.h.

790  {
791  assert(_buffer+index<=_limit);
792 
793  T value = detail::load_unaligned<T>(_buffer + index);
794 
795  if(reverse<T>())
796  value = swap<T>(value);
797  return value;
798  }
Definition: link.h:174
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
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 465 of file byteBuffer.h.

465  {
466  assert(count<=getRemaining());
467  memcpy(dest + dest_offset, _position, count);
468  _position += count;
469  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
std::size_t getRemaining() const
Definition: byteBuffer.h:391
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 817 of file byteBuffer.h.

818  {
819  size_t n = sizeof(T)*count; // bytes
820  assert(n<=getRemaining());
821 
822  if (reverse<T>()) {
823  for(std::size_t i=0; i<count; i++) {
824  values[i] = swap<T>(detail::load_unaligned<T>(_position+i*sizeof(T)));
825  }
826  } else {
827  memcpy(values, _position, n);
828  }
829  _position += n;
830  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
int i
Definition: scan.c:967
std::size_t getRemaining() const
Definition: byteBuffer.h:391
EPICS_ALWAYS_INLINE const char* epics::pvData::ByteBuffer::getArray ( ) const
inline

Definition at line 699 of file byteBuffer.h.

700  {
701  return _buffer;
702  }
EPICS_ALWAYS_INLINE bool epics::pvData::ByteBuffer::getBoolean ( )
inline

Get a boolean value from the byte buffer.

Returns
The value.

Definition at line 611 of file byteBuffer.h.

611 { return GET( int8) != 0; }
int8_t int8
Definition: pvType.h:75
#define GET(T)
Definition: byteBuffer.h:222
EPICS_ALWAYS_INLINE 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 654 of file byteBuffer.h.

654 { return get< int8>(index) != 0; }
const char* epics::pvData::ByteBuffer::getBuffer ( ) const
inline

Get the raw buffer data.

Returns
the raw buffer data.

Definition at line 294 of file byteBuffer.h.

295  {
296  return _buffer;
297  }
EPICS_ALWAYS_INLINE int8 epics::pvData::ByteBuffer::getByte ( )
inline

Get a byte value from the byte buffer.

Returns
The value.

Definition at line 617 of file byteBuffer.h.

617 { return GET( int8); }
int8_t int8
Definition: pvType.h:75
#define GET(T)
Definition: byteBuffer.h:222
EPICS_ALWAYS_INLINE 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 661 of file byteBuffer.h.

661 { return get< int8>(index); }
EPICS_ALWAYS_INLINE double epics::pvData::ByteBuffer::getDouble ( )
inline

Get a double value from the byte buffer.

Returns
The value.

Definition at line 647 of file byteBuffer.h.

647 { return GET(double); }
#define GET(T)
Definition: byteBuffer.h:222
EPICS_ALWAYS_INLINE 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 696 of file byteBuffer.h.

696 { return get<double>(index); }
EPICS_ALWAYS_INLINE float epics::pvData::ByteBuffer::getFloat ( )
inline

Get a float value from the byte buffer.

Returns
The value.

Definition at line 641 of file byteBuffer.h.

641 { return GET( float); }
#define GET(T)
Definition: byteBuffer.h:222
EPICS_ALWAYS_INLINE 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 689 of file byteBuffer.h.

689 { return get< float>(index); }
EPICS_ALWAYS_INLINE int32 epics::pvData::ByteBuffer::getInt ( )
inline

Get a int value from the byte buffer.

Returns
The value.

Definition at line 629 of file byteBuffer.h.

629 { return GET( int32); }
#define GET(T)
Definition: byteBuffer.h:222
int32_t int32
Definition: pvType.h:83
EPICS_ALWAYS_INLINE 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 675 of file byteBuffer.h.

675 { return get< int32>(index); }
std::size_t epics::pvData::ByteBuffer::getLimit ( ) const
inline

Returns this buffer's limit.

Returns
The offset into the raw buffer.

Definition at line 368 of file byteBuffer.h.

369  {
370  return _limit - _buffer;
371  }
EPICS_ALWAYS_INLINE int64 epics::pvData::ByteBuffer::getLong ( )
inline

Get a long value from the byte buffer.

Returns
The value.

Definition at line 635 of file byteBuffer.h.

635 { return GET( int64); }
#define GET(T)
Definition: byteBuffer.h:222
int64_t int64
Definition: pvType.h:87
EPICS_ALWAYS_INLINE 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 682 of file byteBuffer.h.

682 { return get< int64>(index); }
std::size_t epics::pvData::ByteBuffer::getPosition ( ) const
inline

Returns the current position.

Returns
The current position in the raw data.

Definition at line 346 of file byteBuffer.h.

347  {
348  return _position - _buffer;
349  }
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 391 of file byteBuffer.h.

392  {
393  return _limit - _position;
394  }
EPICS_ALWAYS_INLINE int16 epics::pvData::ByteBuffer::getShort ( )
inline

Get a short value from the byte buffer.

Returns
The value.

Definition at line 623 of file byteBuffer.h.

623 { return GET( int16); }
#define GET(T)
Definition: byteBuffer.h:222
int16_t int16
Definition: pvType.h:79
EPICS_ALWAYS_INLINE 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 668 of file byteBuffer.h.

668 { return get< int16>(index); }
EPICS_ALWAYS_INLINE 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 400 of file byteBuffer.h.

401  {
402  return _size;
403  }
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 748 of file byteBuffer.h.

749  {
750  assert(sizeof(T)<=getRemaining());
751 
752  if(reverse<T>())
753  value = swap<T>(value);
754 
755  detail::store_unaligned(_position, value);
756  _position += sizeof(T);
757  }
Definition: link.h:174
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
EPICS_ALWAYS_INLINE void store_unaligned(char *buf, T val)
Definition: byteBuffer.h:191
std::size_t getRemaining() const
Definition: byteBuffer.h:391
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 760 of file byteBuffer.h.

761  {
762  assert(_buffer+index<=_limit);
763 
764  if(reverse<T>())
765  value = swap<T>(value);
766 
767  detail::store_unaligned(_buffer+index, value);
768  }
Definition: link.h:174
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
EPICS_ALWAYS_INLINE void store_unaligned(char *buf, T val)
Definition: byteBuffer.h:191
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 451 of file byteBuffer.h.

451  {
452  assert(count<=getRemaining());
453  memcpy(_position, src + src_offset, count);
454  _position += count;
455  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
std::size_t getRemaining() const
Definition: byteBuffer.h:391
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 801 of file byteBuffer.h.

802  {
803  size_t n = sizeof(T)*count; // bytes
804  assert(n<=getRemaining());
805 
806  if (reverse<T>()) {
807  for(std::size_t i=0; i<count; i++) {
808  detail::store_unaligned(_position+i*sizeof(T), swap<T>(values[i]));
809  }
810  } else {
811  memcpy(_position, values, n);
812  }
813  _position += n;
814  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
EPICS_ALWAYS_INLINE void store_unaligned(char *buf, T val)
Definition: byteBuffer.h:191
int i
Definition: scan.c:967
std::size_t getRemaining() const
Definition: byteBuffer.h:391
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putBoolean ( bool  value)
inline

Put a boolean value into the byte buffer.

Parameters
valueThe value.

Definition at line 519 of file byteBuffer.h.

519 { put< int8>(value ? 1 : 0); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 563 of file byteBuffer.h.

563 { put< int8>(index, value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putByte ( int8  value)
inline

Put a byte value into the byte buffer.

Parameters
valueThe value.

Definition at line 525 of file byteBuffer.h.

525 { put< int8>(value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 570 of file byteBuffer.h.

570 { put< int8>(index, value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putDouble ( double  value)
inline

Put a double value into the byte buffer.

Parameters
valueThe value.

Definition at line 555 of file byteBuffer.h.

555 { put<double>(value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 605 of file byteBuffer.h.

605 { put<double>(index, value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putFloat ( float  value)
inline

Put a float value into the byte buffer.

Parameters
valueThe value.

Definition at line 549 of file byteBuffer.h.

549 { put< float>(value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 598 of file byteBuffer.h.

598 { put< float>(index, value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putInt ( int32  value)
inline

Put an int value into the byte buffer.

Parameters
valueThe value.

Definition at line 537 of file byteBuffer.h.

537 { put< int32>(value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 584 of file byteBuffer.h.

584 { put< int32>(index, value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putLong ( int64  value)
inline

Put a long value into the byte buffer.

Parameters
valueThe value.

Definition at line 543 of file byteBuffer.h.

543 { put< int64>(value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 591 of file byteBuffer.h.

591 { put< int64>(index, value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE void epics::pvData::ByteBuffer::putShort ( int16  value)
inline

Put a short value into the byte buffer.

Parameters
valueThe value.

Definition at line 531 of file byteBuffer.h.

531 { put< int16>(value); }
Definition: link.h:174
EPICS_ALWAYS_INLINE 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 577 of file byteBuffer.h.

577 { put< int16>(index, value); }
Definition: link.h:174
template<typename T >
EPICS_ALWAYS_INLINE 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 493 of file byteBuffer.h.

494  {
495  return sizeof(T)>1 && _reverseEndianess;
496  }
template<>
EPICS_ALWAYS_INLINE bool epics::pvData::ByteBuffer::reverse ( ) const

Definition at line 716 of file byteBuffer.h.

717  {
718  return false;
719  }
template<>
EPICS_ALWAYS_INLINE bool epics::pvData::ByteBuffer::reverse ( ) const

Definition at line 722 of file byteBuffer.h.

723  {
724  return false;
725  }
template<>
EPICS_ALWAYS_INLINE bool epics::pvData::ByteBuffer::reverse ( ) const

Definition at line 728 of file byteBuffer.h.

729  {
730  return false;
731  }
template<>
EPICS_ALWAYS_INLINE bool epics::pvData::ByteBuffer::reverse ( ) const

Definition at line 734 of file byteBuffer.h.

735  {
736  return _reverseFloatEndianess;
737  }
template<>
EPICS_ALWAYS_INLINE bool epics::pvData::ByteBuffer::reverse ( ) const

Definition at line 740 of file byteBuffer.h.

741  {
742  return _reverseFloatEndianess;
743  }
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 339 of file byteBuffer.h.

339  {
340  _position = _buffer;
341  }
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 285 of file byteBuffer.h.

286  {
287  _reverseEndianess = (byteOrder != EPICS_BYTE_ORDER);
288  _reverseFloatEndianess = (byteOrder != EPICS_FLOAT_WORD_ORDER);
289  }
#define EPICS_FLOAT_WORD_ORDER
Definition: osdWireConfig.h:60
#define EPICS_BYTE_ORDER
Definition: osdWireConfig.h:16
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 380 of file byteBuffer.h.

381  {
382  assert(limit<=_size);
383  _limit = _buffer + limit;
384  assert(_position<=_limit);
385  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
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 357 of file byteBuffer.h.

358  {
359  assert(pos<=_size);
360  _position = _buffer + pos;
361  assert(_position<=_limit);
362  }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70

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