Public Member Functions | Protected Attributes

cygnal::Buffer Class Reference

#include <buffer.h>

List of all members.

Public Member Functions

 Buffer ()
 Create a new Buffer with the default size.
 Buffer (size_t nbytes)
 Create a new Buffer with a size other than the default.
 Buffer (const std::string &str)
 Create a new Buffer with a hex string. This is primary used only for testing to create binary data from an easy to read and edit format.
 ~Buffer ()
 Delete the memory allocated for this Buffer.
int corrupt ()
 Corrupt a buffer with random errors. This is used only for testing to make sure we can cleanly handle corruption of the packets.
int corrupt (int factor)
Bufferhex2mem (const std::string &str)
 Encode a Buffer from a hex string.
std::string hexify ()
 Output a debug version of the Buffer's data. This just calls the gnash::Logfile::hexify(), but is more convienient as we don't have to extract the pointer and the byte count to hexify() a Buffer.
std::string hexify (bool ascii)
std::string hexify (Buffer &buf, bool ascii)
void clear ()
 Clear the contents of the buffer by setting all the bytes to zeros.
bool empty ()
 Test to see if the buffer has any data.
Bufferresize ()
 Resize the buffer that holds the data. The new size of the current data is based on the current amount of data within the allocated memory. This is used to make a Buffer the same size as the existing data, and to truncate the unsed portion of the Buffer when copying to the new memory location.
Bufferresize (size_t nbytes)
 Resize the buffer that holds the data. If the size is larger than the existing data, the data is copied into the new region. If the size is smaller than the existing data, the remaining data is truncated when copying to the new memory location.
Buffercopy (boost::uint8_t *data, size_t nbytes)
 Copy data into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (Buffer &buf)
 Copy a Buffer class into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::shared_ptr< Buffer > &buf)
 Copy a Buffer class into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (const std::string &str)
 Copy a string into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (const char *str)
Bufferoperator= (double num)
 Copy a double into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::uint16_t length)
 Copy a short into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::uint8_t byte)
 Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::uint8_t *byte)
 Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (cygnal::Element::amf0_type_e type)
 Copy a AMF0 type into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (bool flag)
Bufferappend (boost::uint8_t *data, size_t nbytes)
 Append data to existing data in the buffer.
Bufferoperator+= (Buffer &buf)
 Append a Buffer class to existing data in the buffer.
Bufferoperator+= (boost::shared_ptr< Buffer > &buf)
 Append a Buffer class to existing data in the buffer.
Bufferoperator+= (const std::string &str)
 Append a string to existing data in the buffer.
Bufferoperator+= (const char *str)
 Append a string to existing data in the buffer.
Bufferoperator+= (double num)
 Append a double to existing data in the buffer.
Bufferoperator+= (boost::uint32_t length)
 Append an integer to existing data in the buffer.
Bufferoperator+= (boost::uint16_t length)
 Append a short to existing data in the buffer.
Bufferoperator+= (boost::uint8_t byte)
 Append a byte to existing data in the buffer.
Bufferoperator+= (char byte)
 Append a byte to existing data in the buffer.
Bufferoperator+= (cygnal::Element::amf0_type_e type)
 Append an AMF0 type to existing data in the buffer.
Bufferoperator+= (bool)
 Append a boolean to existing data in the buffer.
boost::uint8_t * remove (boost::uint8_t c)
 Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.
boost::uint8_t * remove (int index)
 Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.
boost::uint8_t * remove (int start, int range)
 Drop bytes without resizing. This will remove the bytes from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.
boost::uint8_t * begin ()
 Return the base address of the Buffer.
boost::uint8_t * reference ()
const boost::uint8_t * reference () const
boost::uint8_t * end ()
 Return the last address of the Buffer Which is the base address plus the total size of the Buffer.
size_t size ()
 Get the size of the Buffer.
void setSize (size_t nbytes)
 Set the size of the Buffer. Note that this does not resize the Buffer, it merely is a convienient way to set the size field of the Buffer class, and should only be used by low level internal code and testing.
void setPointer (boost::uint8_t *ptr)
 Set the real pointer to a block of Memory.
bool operator== (Buffer &buf)
 Test equivalance against another Buffer. This compares all the data on the current Buffer with the supplied one, so it can be a performance hit. This is primarily only used for testing purposes.
boost::uint8_t operator[] (int index)
 Get the byte at a specified location.
boost::uint8_t * at (int index)
 Get the byte at a specified location.
size_t spaceLeft ()
 How much room is left in the buffer past the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.
size_t allocated ()
 How much room has been allocated before the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.
void setSeekPointer (boost::uint8_t *ptr)
 Set the seek pointer.
void setSeekPointer (off_t offset)
void dump () const
 Dump the internal data of this class in a human readable form. This should only be used for debugging purposes.
void dump (std::ostream &os) const
 Dump the internal data of this class in a human readable form. This should only be used for debugging purposes.
 Buffer ()
 Create a new Buffer with the default size.
 Buffer (size_t nbytes)
 Create a new Buffer with a size other than the default.
 Buffer (const std::string &str)
 ~Buffer ()
 Delete the memory allocated for this Buffer.
int corrupt ()
 Corrupt a buffer with random errors. This is used only for testing to make sure we can cleanly handle corruption of the packets.
int corrupt (int factor)
Bufferhex2mem (const std::string &str)
std::string hexify ()
 Output a debug version of the Buffer's data. This just calls the gnash::Logfile::hexify(), but is more convienient as we don't have to extract the pointer and the byte count to hexify() a Buffer.
std::string hexify (bool ascii)
std::string hexify (Buffer &buf, bool ascii)
void clear ()
 Clear the contents of the buffer by setting all the bytes to zeros.
bool empty ()
 Test to see if the buffer has any data.
Bufferresize ()
 Resize the buffer that holds the data. The new size of the current data is based on the current amount of data within the allocated memory. This is used to make a Buffer the same size as the existing data, and to truncate the unsed portion of the Buffer when copying to the new memory location.
Bufferresize (size_t nbytes)
 Resize the buffer that holds the data. If the size is larger than the existing data, the data is copied into the new region. If the size is smaller than the existing data, the remaining data is truncated when copying to the new memory location.
Buffercopy (boost::uint8_t *data, size_t nbytes)
 Copy data into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (Buffer &buf)
 Copy a Buffer class into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::shared_ptr< Buffer > &buf)
Bufferoperator= (const std::string &str)
 Copy a string into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (const char *str)
Bufferoperator= (double num)
 Copy a double into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::uint16_t length)
 Copy a short into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::uint8_t byte)
 Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (boost::uint8_t *byte)
 Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (cygnal::Element::amf0_type_e type)
 Copy a AMF0 type into the buffer. This overwrites all data, and resets the seek ptr.
Bufferoperator= (bool flag)
Bufferappend (boost::uint8_t *data, size_t nbytes)
 Append data to existing data in the buffer.
Bufferoperator+= (Buffer &buf)
 Append a Buffer class to existing data in the buffer.
Bufferoperator+= (boost::shared_ptr< Buffer > &buf)
Bufferoperator+= (const std::string &str)
 Append a string to existing data in the buffer.
Bufferoperator+= (const char *str)
Bufferoperator+= (double num)
 Append a double to existing data in the buffer.
Bufferoperator+= (boost::uint32_t length)
 Append an integer to existing data in the buffer.
Bufferoperator+= (boost::uint16_t length)
 Append a short to existing data in the buffer.
Bufferoperator+= (boost::uint8_t byte)
 Append a byte to existing data in the buffer.
Bufferoperator+= (char byte)
Bufferoperator+= (cygnal::Element::amf0_type_e type)
 Append an AMF0 type to existing data in the buffer.
Bufferoperator+= (bool)
 Append a boolean to existing data in the buffer.
boost::uint8_t * remove (boost::uint8_t c)
 Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.
boost::uint8_t * remove (int index)
 Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.
boost::uint8_t * remove (int start, int range)
 Drop bytes without resizing. This will remove the bytes from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.
boost::uint8_t * begin ()
 Return the base address of the Buffer.
boost::uint8_t * reference ()
const boost::uint8_t * reference () const
boost::uint8_t * end ()
 Return the last address of the Buffer Which is the base address plus the total size of the Buffer.
size_t size ()
 Get the size of the Buffer.
void setSize (size_t nbytes)
 Set the size of the Buffer. Note that this does not resize the Buffer, it merely is a convienient way to set the size field of the Buffer class, and should only be used by low level internal code and testing.
void setPointer (boost::uint8_t *ptr)
 Set the real pointer to a block of Memory.
bool operator== (Buffer &buf)
 Test equivalance against another Buffer. This compares all the data on the current Buffer with the supplied one, so it can be a performance hit. This is primarily only used for testing purposes.
boost::uint8_t operator[] (int index)
 Get the byte at a specified location.
boost::uint8_t * at (int index)
 Get the byte at a specified location.
size_t spaceLeft ()
 How much room is left in the buffer past the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.
size_t allocated ()
 How much room has been allocated before the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.
void setSeekPointer (boost::uint8_t *ptr)
 Set the seek pointer.
void setSeekPointer (off_t offset)
void dump () const
 Dump the internal data of this class in a human readable form. This should only be used for debugging purposes.
void dump (std::ostream &os) const

Protected Attributes

boost::uint8_t * _seekptr
 This is a pointer to the address in the Buffer to write data to then next time some is appended.
boost::scoped_array
< boost::uint8_t > 
_data
 This is the container of the actual data in this Buffer.
size_t _nbytes
 This is the total allocated size of the Buffer.

Detailed Description

This class is used to hold all data for libamf classes. It is a simplified form of std::vector, but with more knowledge of data types when copying or appending data to make higher level code easier to read.


Constructor & Destructor Documentation

cygnal::Buffer::Buffer (  ) 

Create a new Buffer with the default size.

References _nbytes, and cygnal::NETBUFSIZE.

cygnal::Buffer::Buffer ( size_t  nbytes  ) 

Create a new Buffer with a size other than the default.

References _nbytes.

cygnal::Buffer::Buffer ( const std::string &  str  ) 

Create a new Buffer with a hex string. This is primary used only for testing to create binary data from an easy to read and edit format.

Parameters:
str A hex string, ex... "00 03 05 0a"

References hex2mem().

cygnal::Buffer::~Buffer (  ) 

Delete the memory allocated for this Buffer.

References _data, _nbytes, _seekptr, and CLOCK_REALTIME.

cygnal::Buffer::Buffer (  ) 

Create a new Buffer with the default size.

cygnal::Buffer::Buffer ( size_t  nbytes  ) 

Create a new Buffer with a size other than the default.

cygnal::Buffer::Buffer ( const std::string &  str  ) 
cygnal::Buffer::~Buffer (  ) 

Delete the memory allocated for this Buffer.


Member Function Documentation

size_t cygnal::Buffer::allocated (  )  [inline]

How much room has been allocated before the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.

Returns:
The amoount of unused bytes in the Buffer.

References _data.

Referenced by gnash::RTMPClient::clientFinish(), gnash::RTMP::decodeMsgBody(), gnash::HTTP::formatEchoResponse(), cygnal::EchoTest::formatEchoResponse(), cygnal::OflaDemoTest::formatOflaDemoResponse(), hexify(), operator+=(), gnash::RTMP::sendMsg(), cygnal::RTMPServer::sendToClient(), gnash::RTMP::split(), gnash::Network::writeNet(), gnash::DiskStream::writeToDisk(), and cygnal::Handler::writeToPlugin().

size_t cygnal::Buffer::allocated (  )  [inline]

How much room has been allocated before the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.

Returns:
The amoount of unused bytes in the Buffer.

References _data.

Buffer& cygnal::Buffer::append ( boost::uint8_t *  data,
size_t  nbytes 
)

Append data to existing data in the buffer.

Parameters:
data A pointer to the raw bytes to append to the buffer.
nbytes The number of bytes to append.
Returns:
A reference to a Buffer.
Buffer & cygnal::Buffer::append ( boost::uint8_t *  data,
size_t  nbytes 
)

Append data to existing data in the buffer.

Parameters:
data A pointer to the raw bytes to append to the buffer.
nbytes The number of bytes to append.
Returns:
A reference to a Buffer.

References _data, _seekptr, copy(), and spaceLeft().

Referenced by gnash::HTTP::formatEchoResponse(), cygnal::GatewayTest::formatEchoResponse(), and operator+=().

boost::uint8_t* cygnal::Buffer::at ( int  index  )  [inline]

Get the byte at a specified location.

Parameters:
index The location as a numerical value of the byte to get.
Returns:
A real pointer to the byte at the specified location.

References _data.

boost::uint8_t* cygnal::Buffer::at ( int  index  )  [inline]

Get the byte at a specified location.

Parameters:
index The location as a numerical value of the byte to get.
Returns:
A real pointer to the byte at the specified location.

References _data.

boost::uint8_t* cygnal::Buffer::begin (  )  [inline]

Return the base address of the Buffer.

Returns:
A real pointer to the base address of the Buffer.

References _data.

Referenced by cygnal::RTMPServer::packetRead(), remove(), and cygnal::Handler::writeToPlugin().

boost::uint8_t* cygnal::Buffer::begin (  )  [inline]

Return the base address of the Buffer.

Returns:
A real pointer to the base address of the Buffer.

References _data.

void cygnal::Buffer::clear (  ) 

Clear the contents of the buffer by setting all the bytes to zeros.

Returns:
nothing

References _data, _nbytes, and _seekptr.

Referenced by gnash::HTTP::clearHeader().

void cygnal::Buffer::clear (  ) 

Clear the contents of the buffer by setting all the bytes to zeros.

Returns:
nothing
Buffer & cygnal::Buffer::copy ( boost::uint8_t *  data,
size_t  nbytes 
)

Copy data into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
data A pointer to the raw bytes to copy into the buffer.
nbytes The number of bytes to copy.
Returns:
A reference to a Buffer.

References _data, _nbytes, and _seekptr.

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

Buffer& cygnal::Buffer::copy ( boost::uint8_t *  data,
size_t  nbytes 
)

Copy data into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
data A pointer to the raw bytes to copy into the buffer.
nbytes The number of bytes to copy.
Returns:
A reference to a Buffer.
int cygnal::Buffer::corrupt ( int  factor  ) 

References _data, _nbytes, and gnash::key::i.

int cygnal::Buffer::corrupt (  ) 

Corrupt a buffer with random errors. This is used only for testing to make sure we can cleanly handle corruption of the packets.

Parameters:
factor A divisor to adjust how many errors are created.
Returns:
The number or errors that were created.
Parameters:
factor A divisor to adjust how many errors are created.
Returns:
nothing
int cygnal::Buffer::corrupt (  ) 

Corrupt a buffer with random errors. This is used only for testing to make sure we can cleanly handle corruption of the packets.

Parameters:
factor A divisor to adjust how many errors are created.
Returns:
The number or errors that were created.
int cygnal::Buffer::corrupt ( int  factor  ) 
void cygnal::Buffer::dump (  )  const [inline]

Dump the internal data of this class in a human readable form. This should only be used for debugging purposes.

References dump().

Referenced by dump(), and cygnal::operator<<().

void cygnal::Buffer::dump (  )  const [inline]

Dump the internal data of this class in a human readable form. This should only be used for debugging purposes.

References dump().

Referenced by dump().

void cygnal::Buffer::dump ( std::ostream &  os  )  const

Dump the internal data of this class in a human readable form. This should only be used for debugging purposes.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References _data, _nbytes, _seekptr, and hexify().

void cygnal::Buffer::dump ( std::ostream &  os  )  const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool cygnal::Buffer::empty (  )  [inline]

Test to see if the buffer has any data.

Returns:
true or false
bool cygnal::Buffer::empty (  )  [inline]

Test to see if the buffer has any data.

Returns:
true or false
boost::uint8_t* cygnal::Buffer::end (  )  [inline]

Return the last address of the Buffer Which is the base address plus the total size of the Buffer.

Returns:
A real pointer to the last address of the Buffer with data.

Referenced by hex2mem(), and remove().

boost::uint8_t* cygnal::Buffer::end (  )  [inline]

Return the last address of the Buffer Which is the base address plus the total size of the Buffer.

Returns:
A real pointer to the last address of the Buffer with data.
Buffer& cygnal::Buffer::hex2mem ( const std::string &  str  ) 
Buffer & cygnal::Buffer::hex2mem ( const std::string &  str  ) 

Encode a Buffer from a hex string.

Parameters:
str A hex string, ex... "00 03 05 0a"
Returns:
A reference to a Buffer in host endian format. This is primary used only for testing to create binary data from an easy to read and edit format.

References end(), gnash::key::i, resize(), and size().

Referenced by Buffer().

std::string cygnal::Buffer::hexify (  ) 

Output a debug version of the Buffer's data. This just calls the gnash::Logfile::hexify(), but is more convienient as we don't have to extract the pointer and the byte count to hexify() a Buffer.

Parameters:
ascii True if ASCII characters should be printed, false if only hex is desired.
buf The buffer to hexify().
Returns:
A string of the debug output

References _data, and allocated().

Referenced by dump(), and hexify().

std::string cygnal::Buffer::hexify ( bool  ascii  ) 

References _data, allocated(), and hexify().

std::string cygnal::Buffer::hexify ( cygnal::Buffer buf,
bool  ascii 
)

References allocated(), hexify(), and reference().

std::string cygnal::Buffer::hexify ( bool  ascii  ) 
std::string cygnal::Buffer::hexify (  ) 

Output a debug version of the Buffer's data. This just calls the gnash::Logfile::hexify(), but is more convienient as we don't have to extract the pointer and the byte count to hexify() a Buffer.

Parameters:
ascii True if ASCII characters should be printed, false if only hex is desired.
buf The buffer to hexify().
Returns:
A string of the debug output
std::string cygnal::Buffer::hexify ( Buffer buf,
bool  ascii 
)
Buffer & cygnal::Buffer::operator+= ( cygnal::Element::amf0_type_e  type  ) 

Append an AMF0 type to existing data in the buffer.

Copy a AMF0 type into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
type An AMF0 type.
Returns:
A reference to a Buffer.

References operator+=().

Buffer & cygnal::Buffer::operator+= ( bool  flag  ) 

Append a boolean to existing data in the buffer.

Parameters:
type A boolean.
Returns:
A reference to a Buffer.

References operator+=().

Buffer& cygnal::Buffer::operator+= ( Buffer buf  ) 

Append a Buffer class to existing data in the buffer.

Parameters:
buf A Buffer class containing the data to append.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( boost::shared_ptr< Buffer > &  buf  ) 
Buffer& cygnal::Buffer::operator+= ( const std::string &  str  ) 

Append a string to existing data in the buffer.

Parameters:
str A string containing ASCII data to copy into the buffer.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( const char *  str  ) 
Buffer& cygnal::Buffer::operator+= ( double  num  ) 

Append a double to existing data in the buffer.

Parameters:
num A numeric double value.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( boost::uint32_t  length  ) 

Append an integer to existing data in the buffer.

Parameters:
num A numeric integer value.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( boost::uint16_t  length  ) 

Append a short to existing data in the buffer.

Parameters:
num A numeric short value.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( boost::uint8_t  byte  ) 

Append a byte to existing data in the buffer.

Parameters:
byte A single byte.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( cygnal::Element::amf0_type_e  type  ) 

Append an AMF0 type to existing data in the buffer.

Parameters:
type An AMF0 type.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( bool   ) 

Append a boolean to existing data in the buffer.

Parameters:
type A boolean.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator+= ( char  byte  ) 
Buffer & cygnal::Buffer::operator+= ( Buffer buf  ) 

Append a Buffer class to existing data in the buffer.

Parameters:
buf A Buffer class containing the data to append.
Returns:
A reference to a Buffer.

References allocated(), append(), and reference().

Referenced by operator+=().

Buffer & cygnal::Buffer::operator+= ( boost::shared_ptr< Buffer > &  buf  ) 

Append a Buffer class to existing data in the buffer.

Parameters:
buf A Buffer class containing the data to append.
Returns:
A reference to a Buffer.

References append().

Buffer & cygnal::Buffer::operator+= ( const std::string &  str  ) 

Append a string to existing data in the buffer.

Parameters:
str A string containing ASCII data to copy into the buffer.
Returns:
A reference to a Buffer.

References append().

Buffer & cygnal::Buffer::operator+= ( const char *  str  ) 

Append a string to existing data in the buffer.

Parameters:
str A string containing ASCII data to copy into the buffer.
Returns:
A reference to a Buffer.

References append().

Buffer & cygnal::Buffer::operator+= ( double  num  ) 

Append a double to existing data in the buffer.

Parameters:
num A numeric double value.
Returns:
A reference to a Buffer.

References cygnal::AMF0_NUMBER_SIZE, and append().

Buffer & cygnal::Buffer::operator+= ( boost::uint32_t  length  ) 

Append an integer to existing data in the buffer.

Parameters:
num A numeric integer value.
Returns:
A reference to a Buffer.

References append().

Buffer & cygnal::Buffer::operator+= ( boost::uint16_t  length  ) 

Append a short to existing data in the buffer.

Parameters:
num A numeric short value.
Returns:
A reference to a Buffer.

References append().

Buffer & cygnal::Buffer::operator+= ( boost::uint8_t  byte  ) 

Append a byte to existing data in the buffer.

Parameters:
byte A single byte.
Returns:
A reference to a Buffer.

References _data, _nbytes, and _seekptr.

Buffer & cygnal::Buffer::operator+= ( char  byte  ) 

Append a byte to existing data in the buffer.

Parameters:
byte A single byte.
Returns:
A reference to a Buffer.

References operator+=().

Buffer& cygnal::Buffer::operator= ( boost::uint16_t  length  ) 

Copy a short into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
num A numeric short value.
Returns:
A reference to a Buffer.
Buffer & cygnal::Buffer::operator= ( double  num  ) 

Copy a double into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
num A numeric double value.
Returns:
A reference to a Buffer.

References cygnal::AMF0_NUMBER_SIZE, and copy().

Buffer& cygnal::Buffer::operator= ( Buffer buf  ) 

Copy a Buffer class into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
buf A Buffer class containing the data to copy.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator= ( boost::shared_ptr< Buffer > &  buf  ) 
Buffer& cygnal::Buffer::operator= ( const std::string &  str  ) 

Copy a string into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
str A string containing ASCII data to copy into the buffer.
Returns:
A reference to a Buffer.
Buffer & cygnal::Buffer::operator= ( boost::uint16_t  length  ) 

Copy a short into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
num A numeric short value.
Returns:
A reference to a Buffer.

References copy().

Buffer& cygnal::Buffer::operator= ( double  num  ) 

Copy a double into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
num A numeric double value.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator= ( boost::uint8_t  byte  ) 

Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
byte A single byte.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator= ( cygnal::Element::amf0_type_e  type  ) 

Copy a AMF0 type into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
type An AMF0 type.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator= ( bool  flag  ) 

Copy a boolean into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
flag A boolean.
Returns:
A reference to a Buffer.
Buffer & cygnal::Buffer::operator= ( boost::shared_ptr< Buffer > &  buf  ) 

Copy a Buffer class into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
buf A Buffer class containing the data to copy.
Returns:
A reference to a Buffer.

References copy().

Buffer& cygnal::Buffer::operator= ( boost::uint8_t *  byte  ) 

Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
byte A pointer to a single byte.
Returns:
A reference to a Buffer.
Buffer& cygnal::Buffer::operator= ( const char *  str  ) 
Buffer & cygnal::Buffer::operator= ( cygnal::Element::amf0_type_e  type  ) 

Copy a AMF0 type into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
type An AMF0 type.
Returns:
A reference to a Buffer.

References operator=().

Buffer & cygnal::Buffer::operator= ( bool  flag  ) 

Copy a boolean into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
flag A boolean.
Returns:
A reference to a Buffer.

References operator=().

Buffer & cygnal::Buffer::operator= ( Buffer buf  ) 

Copy a Buffer class into the buffer. This overwrites all data, and resets the seek ptr.

Append a Buffer class to existing data in the buffer.

Parameters:
buf A Buffer class containing the data to copy.
Returns:
A reference to a Buffer.
Parameters:
buf A Buffer class containing the data to append.
Returns:
A reference to a Buffer.

References _nbytes, copy(), reference(), resize(), and size().

Referenced by operator=().

Buffer & cygnal::Buffer::operator= ( boost::uint8_t *  data  ) 

Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
byte A pointer to a single byte.
Returns:
A reference to a Buffer.

References _data.

Buffer & cygnal::Buffer::operator= ( const std::string &  str  ) 

Copy a string into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
str A string containing ASCII data to copy into the buffer.
Returns:
A reference to a Buffer.

References copy().

Buffer & cygnal::Buffer::operator= ( boost::uint8_t  byte  ) 

Copy a byte into the buffer. This overwrites all data, and resets the seek ptr.

Parameters:
byte A single byte.
Returns:
A reference to a Buffer.

References copy().

Buffer & cygnal::Buffer::operator= ( const char *  str  ) 

References copy().

bool cygnal::Buffer::operator== ( Buffer buf  ) 

Test equivalance against another Buffer. This compares all the data on the current Buffer with the supplied one, so it can be a performance hit. This is primarily only used for testing purposes.

Parameters:
buf A reference to a Buffer.
Returns:
A boolean true if the Buffers are indentical.
bool cygnal::Buffer::operator== ( Buffer buf  ) 

Test equivalance against another Buffer. This compares all the data on the current Buffer with the supplied one, so it can be a performance hit. This is primarily only used for testing purposes.

Parameters:
buf A reference to a Buffer.
Returns:
A boolean true if the Buffers are indentical.

References _data, _nbytes, reference(), and size().

boost::uint8_t cygnal::Buffer::operator[] ( int  index  )  [inline]

Get the byte at a specified location.

Parameters:
index The location as a numerical value of the byte to get.
Returns:
The byte at the specified location.

References _data.

boost::uint8_t cygnal::Buffer::operator[] ( int  index  )  [inline]

Get the byte at a specified location.

Parameters:
index The location as a numerical value of the byte to get.
Returns:
The byte at the specified location.

References _data.

const boost::uint8_t* cygnal::Buffer::reference (  )  const [inline]

References _data.

const boost::uint8_t* cygnal::Buffer::reference (  )  const [inline]

References _data.

boost::uint8_t* cygnal::Buffer::reference (  )  [inline]

References _data.

boost::uint8_t* cygnal::Buffer::reference (  )  [inline]
boost::uint8_t* cygnal::Buffer::remove ( int  start,
int  range 
)

Drop bytes without resizing. This will remove the bytes from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.

Parameters:
index The location of the byte to start removing data from the Buffer. This is an numerical value, not a pointer.
start The location of the byte to remove from the Buffer
range The amoiunt of bytes to remove from the Buffer.
Returns:
A real pointer to the base address of the Buffer.
boost::uint8_t * cygnal::Buffer::remove ( int  start  ) 

Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.

Parameters:
index The location of the byte to remove from the Buffer
Returns:
A real pointer to the base address of the Buffer.
Parameters:
start The location of the byte to remove from the Buffer
Returns:
A real pointer to the base address of the Buffer.

References _data, _seekptr, copy(), and end().

boost::uint8_t* cygnal::Buffer::remove ( boost::uint8_t  c  ) 

Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.

Parameters:
byte The byte to remove from the buffer.
Returns:
A real pointer to the base address of the buffer.
boost::uint8_t * cygnal::Buffer::remove ( boost::uint8_t  c  ) 

Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.

Parameters:
byte The byte to remove from the buffer.
Returns:
A real pointer to the base address of the buffer.

References _data, _seekptr, begin(), copy(), end(), and start.

boost::uint8_t * cygnal::Buffer::remove ( int  start,
int  range 
)

Drop bytes without resizing. This will remove the bytes from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.

Parameters:
index The location of the byte to start removing data from the Buffer. This is an numerical value, not a pointer.
start The location of the byte to remove from the Buffer
range The amoiunt of bytes to remove from the Buffer.
Returns:
A real pointer to the base address of the Buffer.
Parameters:
index The location of the byte to start removing data from the Buffer. This is an numerical value, not a pointer.
start The location of the byte to remove from the Buffer
range The amount of bytes to remove from the Buffer.
Returns:
A real pointer to the base address of the Buffer.

References _data, _seekptr, copy(), and end().

boost::uint8_t* cygnal::Buffer::remove ( int  index  ) 

Drop a byte without resizing. This will remove the byte from the Buffer, and then move the remaining data to be in the correct location. This resets the seek pointer.

Parameters:
index The location of the byte to remove from the Buffer
Returns:
A real pointer to the base address of the Buffer.
Buffer& cygnal::Buffer::resize (  ) 

Resize the buffer that holds the data. The new size of the current data is based on the current amount of data within the allocated memory. This is used to make a Buffer the same size as the existing data, and to truncate the unsed portion of the Buffer when copying to the new memory location.

Returns:
A reference to a Buffer.
Buffer & cygnal::Buffer::resize ( size_t  size  ) 

Resize the buffer that holds the data. If the size is larger than the existing data, the data is copied into the new region. If the size is smaller than the existing data, the remaining data is truncated when copying to the new memory location.

Parameters:
nbyte The size to resize the Buffer to.
Returns:
A reference to a Buffer.

References _data, _nbytes, _seekptr, and copy().

Buffer& cygnal::Buffer::resize ( size_t  nbytes  ) 

Resize the buffer that holds the data. If the size is larger than the existing data, the data is copied into the new region. If the size is smaller than the existing data, the remaining data is truncated when copying to the new memory location.

Parameters:
nbyte The size to resize the Buffer to.
Returns:
A reference to a Buffer.
Buffer & cygnal::Buffer::resize (  ) 

Resize the buffer that holds the data. The new size of the current data is based on the current amount of data within the allocated memory. This is used to make a Buffer the same size as the existing data, and to truncate the unsed portion of the Buffer when copying to the new memory location.

Returns:
A reference to a Buffer.

References _data, and _seekptr.

Referenced by hex2mem(), operator=(), and gnash::Network::readNet().

void cygnal::Buffer::setPointer ( boost::uint8_t *  ptr  )  [inline]

Set the real pointer to a block of Memory.

References _data.

void cygnal::Buffer::setPointer ( boost::uint8_t *  ptr  )  [inline]

Set the real pointer to a block of Memory.

References _data.

void cygnal::Buffer::setSeekPointer ( off_t  offset  )  [inline]

References _data.

void cygnal::Buffer::setSeekPointer ( boost::uint8_t *  ptr  )  [inline]

Set the seek pointer.

Parameters:
ptr the real pointer to set the seek pointer to
Returns:
nothing
void cygnal::Buffer::setSeekPointer ( off_t  offset  )  [inline]

References _data.

void cygnal::Buffer::setSeekPointer ( boost::uint8_t *  ptr  )  [inline]

Set the seek pointer.

Parameters:
ptr the real pointer to set the seek pointer to
Returns:
nothing

Referenced by gnash::Network::readNet().

void cygnal::Buffer::setSize ( size_t  nbytes  )  [inline]

Set the size of the Buffer. Note that this does not resize the Buffer, it merely is a convienient way to set the size field of the Buffer class, and should only be used by low level internal code and testing.

Parameters:
nbytes 
Returns:
The size of the Buffer.
void cygnal::Buffer::setSize ( size_t  nbytes  )  [inline]

Set the size of the Buffer. Note that this does not resize the Buffer, it merely is a convienient way to set the size field of the Buffer class, and should only be used by low level internal code and testing.

Parameters:
nbytes 
Returns:
The size of the Buffer.
size_t cygnal::Buffer::size (  )  [inline]
size_t cygnal::Buffer::size (  )  [inline]

Get the size of the Buffer.

Returns:
The size of the Buffer.
size_t cygnal::Buffer::spaceLeft (  )  [inline]

How much room is left in the buffer past the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.

Returns:
The amoount of unused bytes in the Buffer.

References _data.

Referenced by append().

size_t cygnal::Buffer::spaceLeft (  )  [inline]

How much room is left in the buffer past the seek pointer. This is primarily used to see if the buffer is fully populated with data before appending more.

Returns:
The amoount of unused bytes in the Buffer.

References _data.


Member Data Documentation

boost::scoped_array< boost::uint8_t > cygnal::Buffer::_data [protected]

This is the container of the actual data in this Buffer.

Referenced by append(), clear(), copy(), corrupt(), dump(), hexify(), operator+=(), operator=(), operator==(), remove(), resize(), and ~Buffer().

size_t cygnal::Buffer::_nbytes [protected]

This is the total allocated size of the Buffer.

Referenced by Buffer(), clear(), copy(), corrupt(), dump(), operator+=(), operator=(), operator==(), resize(), and ~Buffer().

boost::uint8_t * cygnal::Buffer::_seekptr [protected]

This is a pointer to the address in the Buffer to write data to then next time some is appended.

Referenced by append(), clear(), copy(), dump(), operator+=(), remove(), resize(), and ~Buffer().


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