Gnash  0.8.10
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.


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 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.

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

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

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

Parameters:
sShort 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]
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 resize(), and append().

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]

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