Gnash  0.8.11dev
Public Member Functions
gnash::SimpleBuffer Class Reference

A simple buffer of bytes. More...

#include <SimpleBuffer.h>

List of all members.

Public Member Functions

 SimpleBuffer (size_t capacity=0)
 Construct a SimpleBuffer with an optional initial capacity.
 SimpleBuffer (const SimpleBuffer &b)
 Copy constructor.
SimpleBufferoperator= (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.

Detailed Description

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.


Constructor & Destructor Documentation

gnash::SimpleBuffer::SimpleBuffer ( size_t  capacity = 0)
inline

Construct a SimpleBuffer with an optional initial capacity.

Parameters:
capacityThe 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.

References data(), and size().


Member Function Documentation

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.

Parameters:
inDataData to append. Will be copied.
sizeSize of data to append

References assert, and resize().

Referenced by append(), gnash::sound::LiveSound::appendDecodedData(), operator=(), gnash::amf::Writer::writeData(), gnash::amf::writePlainNumber(), and gnash::amf::writePlainString().

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.

Parameters:
bufSimpleBuffer containing data to append

References append(), data(), and size().

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.

Parameters:
bByte to append.

References gnash::key::b, and resize().

Referenced by replyBWCheck(), sendCheckBW(), sendConnectPacket(), sendCreateStream(), sendDeleteStream(), sendFCSubscribe(), sendPausePacket(), gnash::amf::write(), gnash::amf::Writer::writeNull(), gnash::amf::Writer::writeObject(), and gnash::amf::Writer::writeUndefined().

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.

Parameters:
lLong to append. Will be appended in network order. ie with high order bytes first.

References resize().

Referenced by gnash::rtmp::sendCtrl(), gnash::rtmp::sendServerBW(), gnash::amf::Writer::writeObject(), and gnash::amf::writePlainString().

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.

Parameters:
sShort to append. Will be appended in network order. ie with high order byte first.

References resize().

Referenced by gnash::rtmp::sendCtrl(), gnash::amf::Writer::writeObject(), and gnash::amf::writePlainString().

size_t gnash::SimpleBuffer::capacity ( ) const
inline

Return capacity of the buffer.

boost::uint8_t* gnash::SimpleBuffer::data ( )
inline
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

Assignment operator.

The assignment op will not reset capacity

References append(), and resize().

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 append(), appendByte(), appendNetworkLong(), appendNetworkShort(), and operator=().

size_t gnash::SimpleBuffer::size ( ) const
inline

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