Gnash
0.8.10
|
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. | |
SimpleBuffer (const SimpleBuffer &b) | |
Copy constructor. | |
SimpleBuffer & | operator= (const SimpleBuffer &b) |
Assignment operator. | |
bool | empty () const |
Return true if buffer is empty. | |
size_t | size () const |
Return size of the buffer. | |
size_t | capacity () const |
Return capacity of the buffer. | |
boost::uint8_t * | data () |
Get a pointer to start of data. May be NULL if size==0. | |
const boost::uint8_t * | data () const |
Get a pointer to start of data. May be NULL if size==0. | |
void | resize (size_t newSize) |
Resize the buffer. | |
void | reserve (size_t newCapacity) |
Ensure at least 'newCapacity' bytes are allocated for this buffer. | |
void | append (const void *inData, size_t size) |
Append data to the buffer. | |
void | appendByte (const boost::uint8_t b) |
Append a byte to the buffer. | |
void | appendNetworkShort (const boost::uint16_t s) |
Append 2 bytes to the buffer. | |
void | appendNetworkLong (const boost::uint32_t l) |
Append 4 bytes to the buffer. | |
void | append (const SimpleBuffer &buf) |
Append data to the buffer. |
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.
gnash::SimpleBuffer::SimpleBuffer | ( | size_t | capacity = 0 | ) | [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. |
gnash::SimpleBuffer::SimpleBuffer | ( | const SimpleBuffer & | b | ) | [inline] |
Copy constructor.
The copy ctor will set capacity to be as small as required to hold the size of the model buffer.
void gnash::SimpleBuffer::append | ( | const void * | inData, |
size_t | size | ||
) | [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(), and assert.
Referenced by gnash::amf::writePlainString(), gnash::amf::writePlainNumber(), gnash::amf::Writer::writeData(), gnash::sound::LiveSound::appendDecodedData(), operator=(), and append().
void gnash::SimpleBuffer::append | ( | const SimpleBuffer & | buf | ) | [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 |
References append().
void gnash::SimpleBuffer::appendByte | ( | const boost::uint8_t | b | ) | [inline] |
Append a byte to the buffer.
The buffer will be appropriately resized to have space.
b | Byte to append. |
References resize(), and gnash::key::b.
Referenced by gnash::amf::write(), gnash::amf::Writer::writeObject(), gnash::amf::Writer::writeUndefined(), gnash::amf::Writer::writeNull(), sendConnectPacket(), sendCheckBW(), replyBWCheck(), sendPausePacket(), sendCreateStream(), sendDeleteStream(), and sendFCSubscribe().
void gnash::SimpleBuffer::appendNetworkLong | ( | const boost::uint32_t | l | ) | [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::amf::writePlainString(), gnash::amf::Writer::writeObject(), gnash::rtmp::sendServerBW(), and gnash::rtmp::sendCtrl().
void gnash::SimpleBuffer::appendNetworkShort | ( | const boost::uint16_t | s | ) | [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::amf::writePlainString(), gnash::amf::Writer::writeObject(), and gnash::rtmp::sendCtrl().
size_t gnash::SimpleBuffer::capacity | ( | ) | const [inline] |
Return capacity of the buffer.
boost::uint8_t* gnash::SimpleBuffer::data | ( | ) | [inline] |
Get a pointer to start of data. May be NULL if size==0.
Referenced by gnash::sound::LiveSound::getDecodedData(), gnash::rtmp::RTMP::call(), gnash::rtmp::RTMP::play(), gnash::rtmp::payloadData(), and gnash::rtmp::payloadEnd().
const boost::uint8_t* gnash::SimpleBuffer::data | ( | ) | const [inline] |
Get a pointer to start of data. May be NULL if size==0.
bool gnash::SimpleBuffer::empty | ( | ) | const [inline] |
Return true if buffer is empty.
SimpleBuffer& gnash::SimpleBuffer::operator= | ( | const SimpleBuffer & | b | ) | [inline] |
void gnash::SimpleBuffer::reserve | ( | size_t | newCapacity | ) | [inline] |
Ensure at least 'newCapacity' bytes are allocated for this buffer.
Referenced by resize().
void gnash::SimpleBuffer::resize | ( | size_t | newSize | ) | [inline] |
Resize the buffer.
References reserve().
Referenced by operator=(), append(), appendByte(), appendNetworkShort(), and appendNetworkLong().
size_t gnash::SimpleBuffer::size | ( | ) | const [inline] |
Return size of the buffer.
Referenced by gnash::sound::LiveSound::getDecodedData(), gnash::sound::LiveSound::decodedSamplesAhead(), gnash::rtmp::RTMP::call(), gnash::rtmp::RTMP::play(), gnash::rtmp::payloadSize(), and gnash::rtmp::payloadEnd().