|
WSF
|
#include <UtBuffer.hpp>
Public Member Functions | |
| UtBuffer (int aBytes) | |
| Construct the buffer with a grow-able buffer of size aBytes. | |
| UtBuffer (char *aData, int aBytes, bool aCanGrow=false) | |
| Construct the buffer with a user buffer, see SetBuffer(). | |
| UtBuffer (const UtBuffer &aSrc) | |
| Construct a copy of aSrc. | |
| UtBuffer () | |
| Construct the buffer with a default size, and allow growth. | |
| UtBuffer & | operator= (const UtBuffer &)=delete |
| ~UtBuffer () | |
| void | EnableByteSwap (bool aSwapBytes) |
| Disable or Enable byte swapping. | |
| void | SetBigEndian () |
| Enable byte swapping if the local machine is little-endian. | |
| void | SetLittleEndian () |
| Enable byte-swapping if the local machine is big-endian. | |
| void | SetNativeByteOrder () |
| Disable byte swapping. | |
| void | Dispose () |
| void | SetBuffer (char *aData, size_t aBytes, bool aCanGrow=false) |
| void | SetPutPos (size_t aPos) |
| Set the current offset used to put data. | |
| size_t & | GetPutPos () |
| Get the current offset used to put data. | |
| size_t | GetPutPos () const |
| Set the current offset used to put data. | |
| void | SetGetPos (size_t aPos) |
| Set the current offset used to get data. | |
| size_t & | GetGetPos () |
| Get the current offset used to get data. | |
| size_t | GetGetPos () const |
| Get the current offset used to get data. | |
| char * | GetBuffer () |
| Returns a pointer to the internal buffer. | |
| const char * | GetBuffer () const |
| Returns a pointer to the internal buffer. | |
| size_t | GetBytes () const |
| Returns the size of the internal buffer. | |
| void | PutRaw (const char *aBuffer, size_t aBytes) |
| Writes a sequence of aBytes to the buffer. | |
| void | GetRaw (char *aBuffer, size_t aBytes) |
| Reads a sequence of aBytes to the buffer. | |
| void | Reset () |
| Set the put/get positions to the start of the buffer. | |
| void | Move (size_t aBeginOffset, size_t aEndOffset, size_t aNewBegin) |
| Move a set of bytes within the buffer. | |
| void | Grow (size_t aNewSize) |
| Grow the buffer so it is at least as large as aNewSize. | |
| void | GrowBy (size_t aBytes) |
| Grow the buffer by an increment of at least aBytes. | |
| size_t | GetValidBytes () const |
| Return the difference between the write position and the read position. | |
| void | SwapBuffer (UtBuffer &aRhs) |
| Swap the internal buffers between this and aRhs. | |
| void * | ReleaseBuffer () |
| template<typename T> | |
| void | Put (const T &aVal) |
| template<typename T> | |
| void | Get (T &aVal) |
| bool | CheckPutSpace (size_t aPutSize) |
Static Public Attributes | |
| static const int | cDEFAULT_BUFFER_SIZE = 1024 |
Protected Member Functions | |
| template<int BYTES> | |
| void | PutP (const char *aBuffer) |
| template<int BYTES> | |
| void | GetP (char *aBuffer) |
Protected Attributes | |
| char * | mBuffer |
| size_t | mBytes |
| size_t | mGetPos |
| size_t | mPutPos |
| bool | mCanGrow |
| bool | mSwapBytes |
A simple buffer with operations to read/write to memory. Note: Put methods will grow the buffer if the 'grow' option is set. Otherwise, all Put and Get methods require the user to know that there is enough space to do the operation!
|
inline |
Construct the buffer with a grow-able buffer of size aBytes.
References mBuffer, mCanGrow, SetBigEndian(), and SetBuffer().
Referenced by operator=(), SwapBuffer(), and UtBuffer().
|
inline |
Construct the buffer with a user buffer, see SetBuffer().
References mBuffer, mCanGrow, SetBigEndian(), and SetBuffer().
|
inline |
Construct a copy of aSrc.
References mBuffer, mBytes, mCanGrow, mGetPos, mPutPos, mSwapBytes, and UtBuffer().
|
inline |
Construct the buffer with a default size, and allow growth.
References cDEFAULT_BUFFER_SIZE, mBuffer, mCanGrow, SetBigEndian(), and SetBuffer().
|
inline |
References Dispose().
|
inline |
|
inline |
References mBuffer, and mCanGrow.
Referenced by SetBuffer(), and ~UtBuffer().
|
inline |
Disable or Enable byte swapping.
References mSwapBytes.
Referenced by SetBigEndian(), SetLittleEndian(), and SetNativeByteOrder().
|
inline |
Get a basic type from the buffer. This should only be used for basic types (char, int, float) This will perform a byte-swap if that option is enabled
References GetP().
|
inline |
Returns a pointer to the internal buffer.
References mBuffer.
Referenced by UtPackMessageStream::ReadMessageFromIStream(), and UtPackMessageStreamO::Write().
|
inline |
Returns a pointer to the internal buffer.
References mBuffer.
|
inline |
Returns the size of the internal buffer.
References mBytes.
|
inline |
Get the current offset used to get data.
References mGetPos.
|
inline |
Get the current offset used to get data.
References mGetPos.
|
inlineprotected |
References mBuffer, mGetPos, and mSwapBytes.
Referenced by Get().
|
inline |
Get the current offset used to put data.
References mPutPos.
Referenced by UtPackMessageStream::ReadMessageFromIStream(), and UtPackMessageStreamO::Write().
|
inline |
Set the current offset used to put data.
References mPutPos.
|
inline |
|
inline |
|
inline |
| void UtBuffer::GrowBy | ( | size_t | aBytes | ) |
Grow the buffer by an increment of at least aBytes.
Enlarges the buffer to a new size.
References mBuffer, and mBytes.
Referenced by CheckPutSpace(), and Grow().
| void UtBuffer::Move | ( | size_t | aBeginOffset, |
| size_t | aEndOffset, | ||
| size_t | aNewBegin ) |
Move a set of bytes within the buffer.
References mBuffer.
References UtBuffer().
|
inline |
Put a basic type into the buffer. This should only be used for basic types (char, int, float). This will perform a byte-swap if that option is enabled
References PutP().
Referenced by UtPackMessageStreamO::Write(), and UtPackMessageStream::WriteMessageToOStream().
|
inlineprotected |
References CheckPutSpace(), mBuffer, mPutPos, and mSwapBytes.
Referenced by Put().
|
inline |
Writes a sequence of aBytes to the buffer.
References CheckPutSpace(), mBuffer, and mPutPos.
|
inline |
Set the put/get positions to the start of the buffer.
References mGetPos, and mPutPos.
Referenced by UtPackMessageStreamO::Write(), and UtPackMessageStream::WriteMessageToOStream().
| void UtBuffer::SetBigEndian | ( | ) |
Enable byte swapping if the local machine is little-endian.
Enables translation of calls to Put() and Get() to/from big endian.
References EnableByteSwap().
Referenced by UtBuffer(), UtBuffer(), and UtBuffer().
|
inline |
Use a user-created buffer.
| aData | Pointer to the buffer |
| aBytes | Length of the buffer in bytes |
| aCanGrow | If 'true', UtBuffer takes ownership of the buffer and allows resizing If 'false', UtBuffer will not delete the buffer or resize. |
References Dispose(), mBuffer, mBytes, mCanGrow, mGetPos, and mPutPos.
Referenced by UtBuffer(), UtBuffer(), and UtBuffer().
|
inline |
Set the current offset used to get data.
References mGetPos.
Referenced by UtPackMessageStreamO::Write().
| void UtBuffer::SetLittleEndian | ( | ) |
Enable byte-swapping if the local machine is big-endian.
References EnableByteSwap().
| void UtBuffer::SetNativeByteOrder | ( | ) |
Disable byte swapping.
Configures Put() and Get() to use native byte ordering.
References EnableByteSwap().
|
inline |
Set the current offset used to put data.
References mPutPos.
Referenced by UtPackMessageStream::ReadMessageFromIStream(), UtPackMessageStreamO::Write(), and UtPackMessageStream::WriteMessageToOStream().
|
inline |
Swap the internal buffers between this and aRhs.
References mBuffer, mBytes, mCanGrow, mGetPos, mPutPos, std::swap(), and UtBuffer().
|
static |
Referenced by UtBuffer().
|
protected |
Referenced by Dispose(), GetBuffer(), GetBuffer(), GetP(), GetRaw(), GrowBy(), Move(), PutP(), PutRaw(), ReleaseBuffer(), SetBuffer(), SwapBuffer(), UtBuffer(), UtBuffer(), UtBuffer(), UtBuffer(), and UtPackMessageStreamO::Write().
|
protected |
Referenced by CheckPutSpace(), GetBytes(), Grow(), GrowBy(), ReleaseBuffer(), SetBuffer(), SwapBuffer(), and UtBuffer().
|
protected |
Referenced by CheckPutSpace(), Dispose(), SetBuffer(), SwapBuffer(), UtBuffer(), UtBuffer(), UtBuffer(), and UtBuffer().
|
protected |
Referenced by GetGetPos(), GetGetPos(), GetP(), GetRaw(), GetValidBytes(), Reset(), SetBuffer(), SetGetPos(), SwapBuffer(), and UtBuffer().
|
protected |
Referenced by CheckPutSpace(), GetPutPos(), GetPutPos(), GetValidBytes(), PutP(), PutRaw(), Reset(), SetBuffer(), SetPutPos(), SwapBuffer(), and UtBuffer().
|
protected |
Referenced by EnableByteSwap(), GetP(), PutP(), and UtBuffer().