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

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:
inData Data to append. Will be copied.
size Size of data to append

References resize().

Referenced by append(), and operator=().

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:
buf SimpleBuffer 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:
b Byte to append.

References resize().

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

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:
l Long to append. Will be appended in network order. ie with high order bytes first.

References resize().

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:
s Short to append. Will be appended in network order. ie with high order byte first.

References resize().

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 append(), gnash::rtmp::payloadData(), gnash::rtmp::payloadEnd(), and SimpleBuffer().

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]

Return size of the buffer.

Referenced by append(), gnash::rtmp::payloadEnd(), gnash::rtmp::payloadSize(), and SimpleBuffer().


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