Gnash  0.8.11dev
Public Member Functions | List of all members
gnash::SimpleBuffer Class Reference

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...
 
SimpleBufferoperator= (const SimpleBuffer &b)=delete
 
SimpleBufferoperator= (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...
 

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

§ SimpleBuffer() [1/3]

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.

References gnash::key::b, and operator=().

§ SimpleBuffer() [2/3]

gnash::SimpleBuffer::SimpleBuffer ( SimpleBuffer &&  )
default

Move constructor.

§ SimpleBuffer() [3/3]

gnash::SimpleBuffer::SimpleBuffer ( const SimpleBuffer b)
delete

Copy (construction) not allowed.

Member Function Documentation

§ append() [1/2]

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

Referenced by append(), gnash::registerSharedObjectNative(), gnash::amf::writePlainNumber(), and gnash::amf::writePlainString().

§ append() [2/2]

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

§ appendByte()

void gnash::SimpleBuffer::appendByte ( const std::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(), and gnash::amf::write().

§ appendNetworkLong()

void gnash::SimpleBuffer::appendNetworkLong ( const std::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::registerSharedObjectNative(), gnash::rtmp::sendCtrl(), gnash::rtmp::sendServerBW(), and gnash::amf::writePlainString().

§ appendNetworkShort()

void gnash::SimpleBuffer::appendNetworkShort ( const std::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::registerSharedObjectNative(), gnash::rtmp::sendCtrl(), and gnash::amf::writePlainString().

§ capacity()

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

Return capacity of the buffer.

§ data() [1/2]

std::uint8_t* gnash::SimpleBuffer::data ( )
inline

§ data() [2/2]

const std::uint8_t* gnash::SimpleBuffer::data ( ) const
inline

Get a pointer to start of data. May be NULL if size==0.

§ empty()

bool gnash::SimpleBuffer::empty ( ) const
inline

Return true if buffer is empty.

§ operator=() [1/2]

SimpleBuffer& gnash::SimpleBuffer::operator= ( const SimpleBuffer b)
delete

Referenced by SimpleBuffer().

§ operator=() [2/2]

SimpleBuffer& gnash::SimpleBuffer::operator= ( SimpleBuffer &&  )
default

Move assignment is okay.

§ reserve()

void gnash::SimpleBuffer::reserve ( size_t  newCapacity)
inline

Ensure at least 'newCapacity' bytes are allocated for this buffer.

Referenced by resize().

§ resize()

void gnash::SimpleBuffer::resize ( size_t  newSize)
inline

§ size()

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

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