Gnash
0.8.11dev
|
A simple buffer of bytes. More...
#include <SimpleBuffer.h>
Public Member Functions | |
SimpleBuffer (size_t capacity=0) | |
Construct a SimpleBuffer with an optional initial capacity. More... | |
SimpleBuffer (SimpleBuffer &&)=default | |
Move constructor. More... | |
SimpleBuffer (const SimpleBuffer &b)=delete | |
Copy (construction) not allowed. More... | |
SimpleBuffer & | operator= (const SimpleBuffer &b)=delete |
SimpleBuffer & | operator= (SimpleBuffer &&)=default |
Move assignment is okay. More... | |
bool | empty () const |
Return true if buffer is empty. More... | |
size_t | size () const |
Return size of the buffer. More... | |
size_t | capacity () const |
Return capacity of the buffer. More... | |
std::uint8_t * | data () |
Get a pointer to start of data. May be NULL if size==0. More... | |
const std::uint8_t * | data () const |
Get a pointer to start of data. May be NULL if size==0. More... | |
void | resize (size_t newSize) |
Resize the buffer. More... | |
void | reserve (size_t newCapacity) |
Ensure at least 'newCapacity' bytes are allocated for this buffer. More... | |
void | append (const void *inData, size_t size) |
Append data to the buffer. More... | |
void | appendByte (const std::uint8_t b) |
Append a byte to the buffer. More... | |
void | appendNetworkShort (const std::uint16_t s) |
Append 2 bytes to the buffer. More... | |
void | appendNetworkLong (const std::uint32_t l) |
Append 4 bytes to the buffer. More... | |
void | append (const SimpleBuffer &buf) |
Append data to the buffer. More... | |
A simple buffer of bytes.
This class is fully inlined and just aiming to provide RIIA and unified view of memory buffers. It is a kind of a std::vector with a reduced interface in the intentions of the author.
|
inline |
Construct a SimpleBuffer with an optional initial capacity.
capacity | The initial buffer capacity. This is the amount of bytes you can append to the buffer before a new reallocation will occur. |
References gnash::key::b, and operator=().
|
default |
Move constructor.
|
delete |
Copy (construction) not allowed.
|
inline |
Append data to the buffer.
The buffer will be appropriately resized to have space for the incoming data. The data will be copied.
inData | Data to append. Will be copied. |
size | Size of data to append |
References resize().
Referenced by append(), gnash::registerSharedObjectNative(), gnash::amf::writePlainNumber(), and gnash::amf::writePlainString().
|
inline |
Append data to the buffer.
The buffer will be appropriately resized to have space for the incoming data. The data will be copied.
buf | SimpleBuffer containing data to append |
|
inline |
Append a byte to the buffer.
The buffer will be appropriately resized to have space.
b | Byte to append. |
References gnash::key::b, and resize().
Referenced by replyBWCheck(), sendCheckBW(), sendConnectPacket(), sendCreateStream(), sendDeleteStream(), sendFCSubscribe(), sendPausePacket(), and gnash::amf::write().
|
inline |
Append 4 bytes to the buffer.
The buffer will be appropriately resized to have space.
l | Long to append. Will be appended in network order. ie with high order bytes first. |
References resize().
Referenced by gnash::registerSharedObjectNative(), gnash::rtmp::sendCtrl(), gnash::rtmp::sendServerBW(), and gnash::amf::writePlainString().
|
inline |
Append 2 bytes to the buffer.
The buffer will be appropriately resized to have space.
s | Short to append. Will be appended in network order. ie with high order byte first. |
References resize().
Referenced by gnash::registerSharedObjectNative(), gnash::rtmp::sendCtrl(), and gnash::amf::writePlainString().
|
inline |
Return capacity of the buffer.
|
inline |
Get a pointer to start of data. May be NULL if size==0.
Referenced by append(), gnash::rtmp::RTMP::call(), gnash::SWF::StreamSoundBlockTag::loader(), gnash::rtmp::payloadData(), gnash::rtmp::payloadEnd(), gnash::rtmp::RTMP::play(), gnash::registerLocalConnectionNative(), and gnash::sound::StreamingSound::StreamingSound().
|
inline |
Get a pointer to start of data. May be NULL if size==0.
|
inline |
Return true if buffer is empty.
|
delete |
Referenced by SimpleBuffer().
|
default |
Move assignment is okay.
|
inline |
Ensure at least 'newCapacity' bytes are allocated for this buffer.
Referenced by resize().
|
inline |
Resize the buffer.
References reserve().
Referenced by append(), appendByte(), appendNetworkLong(), appendNetworkShort(), and gnash::SWF::StreamSoundBlockTag::loader().
|
inline |
Return size of the buffer.
Referenced by append(), gnash::rtmp::RTMP::call(), gnash::rtmp::payloadEnd(), gnash::rtmp::payloadSize(), gnash::rtmp::RTMP::play(), and gnash::sound::StreamingSound::StreamingSound().