limal::ByteBuffer Class Reference
Buffer for storing binary data.
More...
#include <ByteBuffer.hpp>
List of all members.
Public Member Functions |
| ByteBuffer () |
| ByteBuffer (const char *str) |
| ByteBuffer (const char *ptr, size_t len) |
| ByteBuffer (const ByteBuffer &buf) |
| ~ByteBuffer () |
void | clear () |
| Remove all data from the ByteBuffer.
|
bool | empty () const |
| Return true if the ByteBuffer is empty (size() == 0).
|
size_t | size () const |
| Return the number of bytes in this ByteBuffer.
|
const char * | data () const |
| Returns a pointer to the data stored in the ByteBuffer.
|
char | at (size_t pos) const |
| Return the byte at position pos.
|
void | append (const char *ptr, size_t len) |
| Append new data to this ByteBuffer object.
|
void | append (char c) |
| Append a new byte to this ByteBuffer object.
|
ByteBuffer & | operator= (const ByteBuffer &buf) |
| Assigns buf to this ByteBuffer object.
|
const char & | operator[] (size_t pos) const |
| Return the byte at position pos
|
char & | operator[] (size_t pos) |
| Return the byte at position pos
|
ByteBuffer & | operator+= (const ByteBuffer &buf) |
| Appends data from the ByteBuffer object buf.
|
Private Attributes |
BLOCXX_NAMESPACE::COWIntrusiveReference
< ByteBufferImpl > | m_impl |
Friends |
std::ostream & | operator<< (std::ostream &out, const ByteBuffer &buf) |
bool | operator== (const ByteBuffer &l, const ByteBuffer &r) |
bool | operator!= (const ByteBuffer &l, const ByteBuffer &r) |
bool | operator< (const ByteBuffer &l, const ByteBuffer &r) |
bool | operator> (const ByteBuffer &l, const ByteBuffer &r) |
bool | operator<= (const ByteBuffer &l, const ByteBuffer &r) |
bool | operator>= (const ByteBuffer &l, const ByteBuffer &r) |
ByteBuffer | operator+ (const ByteBuffer &b1, const ByteBuffer &b2) |
Detailed Description
Buffer for storing binary data.
The class implements a byte buffer useful for manipulating memory areas with custom data.
It is reference counted and supports copy on write functionality.
Constructor & Destructor Documentation
limal::ByteBuffer::ByteBuffer |
( |
|
) |
|
limal::ByteBuffer::ByteBuffer |
( |
const char * |
str |
) |
|
Create a ByteBuffer object and initialize it with the C string provided in str. The size is determined using the strlen(str) function.
- Parameters:
-
| str | Pointer to a '\0' terminated C string. |
- Exceptions:
-
limal::ByteBuffer::ByteBuffer |
( |
const char * |
ptr, |
|
|
size_t |
len | |
|
) |
| | |
Create a ByteBuffer object that will contain a copy of the given character array ptr and its size given in len.
- Parameters:
-
| ptr | Pointer to a character array to copy from. |
| len | The length of the character array in ptr. |
- Exceptions:
-
limal::ByteBuffer::ByteBuffer |
( |
const ByteBuffer & |
buf |
) |
|
Create a new ByteBuffer object that is a shared copy of an another ByteBuffer object.
Upon return, both objects will point to the same underlying byte buffer. This state will remain until one of the objects is modified (copy on write).
- Parameters:
-
limal::ByteBuffer::~ByteBuffer |
( |
|
) |
|
Member Function Documentation
void limal::ByteBuffer::append |
( |
char |
c |
) |
|
Append a new byte to this ByteBuffer object.
- Parameters:
-
| c | The new byte to append. |
- Exceptions:
-
void limal::ByteBuffer::append |
( |
const char * |
ptr, |
|
|
size_t |
len | |
|
) |
| | |
Append new data to this ByteBuffer object.
- Parameters:
-
| ptr | Pointer to a character array to copy from. |
| len | The length of the character array in ptr. |
- Exceptions:
-
char limal::ByteBuffer::at |
( |
size_t |
pos |
) |
const |
Return the byte at position pos.
- Returns:
- Return the byte at position pos.
- Exceptions:
-
| blocxx::OutOfBoundsException | if the position is bigger than the number of bytes in this ByteBuffer. |
void limal::ByteBuffer::clear |
( |
|
) |
|
const char* limal::ByteBuffer::data |
( |
|
) |
const |
Returns a pointer to the data stored in the ByteBuffer.
- Returns:
- Returns a pointer to the data.
bool limal::ByteBuffer::empty |
( |
|
) |
const |
Appends data from the ByteBuffer object buf.
Appends data from the specified ByteBuffer object buf to the end of this ByteBuffer object and returns a reference to this ByteBuffer object.
- Parameters:
-
- Returns:
- A reference to this ByteBuffer object.
- Exceptions:
-
char& limal::ByteBuffer::operator[] |
( |
size_t |
pos |
) |
|
Return the byte at position pos
- Parameters:
-
| pos | The position of the byte which should be returned. |
- Returns:
- Read-Write reference to the byte at the specified position pos.
- Exceptions:
-
| blocxx::OutOfBoundsException | if position is bigger than the size of this ByteBuffer. |
const char& limal::ByteBuffer::operator[] |
( |
size_t |
pos |
) |
const |
Return the byte at position pos
- Parameters:
-
| pos | The position of the byte which should be returned. |
- Returns:
- Read-Only reference to the byte at the specified position pos.
- Exceptions:
-
| blocxx::OutOfBoundsException | if position is bigger than the size of this ByteBuffer. |
size_t limal::ByteBuffer::size |
( |
|
) |
const |
Friends And Related Function Documentation
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const ByteBuffer & |
buf | |
|
) |
| | [friend] |
A stream output operator for debugging purposes.
- Returns:
- True if the ByteBuffer object l is less than or equal to the ByteBuffer object r; otherwise false.
- Returns:
- True if the ByteBuffer object l is greater then or equal to the ByteBuffer object r; otherwise false.
Member Data Documentation
The documentation for this class was generated from the following file: