|
CeresEngine 0.2.0
A game development framework
|
Represents a secure buffer i.e. More...
#include <CeresEngine/Foundation/Buffer.hpp>
Public Types | |
| using | Iterator = Byte * |
| The buffer iterator. | |
| using | ConstIterator = const Byte * |
| The buffer const iterator. | |
Public Member Functions | |
| Buffer () noexcept | |
| Creates a new empty buffer. | |
| Buffer (std::nullptr_t) noexcept | |
| Creates a new null buffer. | |
| Buffer (size_t size) noexcept | |
| Creates a new buffer with "size" bytes preallocated. | |
| Buffer (Byte *buffer, size_t size, bool copy=false) noexcept | |
| Creates a new buffer by referecning another raw buffer. | |
| Buffer (const Byte *buffer, size_t size) noexcept | |
| Creates a new buffer by copying another raw buffer. | |
| Buffer (std::initializer_list< unsigned char > bytes) noexcept | |
| Creates a new buffer using a initializer list. | |
| Buffer (const Buffer &other) noexcept=delete | |
| Creates a new buffer by creating a copy of another. | |
| Buffer & | operator= (const Buffer &other) noexcept=delete |
| Assigns this buffer a copy of another. | |
| Buffer (Buffer &&other) noexcept | |
| Creates a new buffer by moving another. | |
| Buffer & | operator= (Buffer &&other) noexcept |
| Assigns this buffer another buffer's content by moving it. | |
| ~Buffer () noexcept | |
| Destroys and releases the buffer content. | |
| Buffer | copy () const noexcept |
| Creates a explicit buffer copy. | |
| Byte * | data () noexcept |
| Gets a pointer to the raws buffer data. | |
| const Byte * | data () const noexcept |
| Gets a pointer to the raws buffer data. | |
| Byte * | buffer () noexcept |
| Gets a pointer to the raws buffer data. | |
| const Byte * | buffer () const noexcept |
| Gets a pointer to the raws buffer data. | |
| size_t | size () const noexcept |
| Gets the number of bytes currently allocated in the buffer. | |
| size_t | capacity () const noexcept |
| Gets the buffer capacity. | |
| bool | empty () const noexcept |
| Checks if the buffer is currently empty (i.e. | |
| bool | owns () const noexcept |
| Checks if the buffer is currently owned. | |
| bool | valid () const noexcept |
| Checks if the buffer is valid. | |
| Iterator | begin () noexcept |
| Gets a iterator that points to the begining of the buffer. | |
| Iterator | end () noexcept |
| Gets a iterator that points to the end of the buffer. | |
| ConstIterator | begin () const noexcept |
| Gets a iterator that points to the beginning of the buffer. | |
| ConstIterator | end () const noexcept |
| Gets a iterator that points to the end of the buffer. | |
| ConstIterator | cbegin () const noexcept |
| Gets a iterator that points to the beginning of the buffer. | |
| ConstIterator | cend () const noexcept |
| Gets a iterator that points to the end of the buffer. | |
| bool | operator== (const Buffer &other) const noexcept |
| Compares a buffer for equality If either buffer contain the same address and size, retuns true. | |
| bool | operator!= (const Buffer &other) const noexcept |
| Compares a buffer for inequality If either buffer contain the same address and size, retuns false. | |
| Byte & | operator[] (size_t offset) noexcept |
| Accesses a buffer element by its offset. | |
| Byte | operator[] (size_t offset) const noexcept |
| Accesses a buffer element by its offset. | |
| operator bool () const noexcept | |
| Checks if the buffer is valid (i.e. | |
| operator const unsigned char * () const noexcept | |
| operator const char * () const noexcept | |
| operator unsigned char * () noexcept | |
| operator char * () noexcept | |
| void | resize (size_t newSize) noexcept |
| Resizes the buffer to be able to store up-to "newSize" bytes. | |
| void | reserve (size_t newCapacity) noexcept |
| Reservers at least newCapacity bytes in the buffer. | |
| void | own () noexcept |
| Transforms a unowned buffer into a owned buffer. | |
| void | append (const Buffer &buffer) noexcept |
| Appends a buffer to the end of this buffer. | |
| void | write (const char *buf, size_t length) noexcept |
| Writes buf to the end of the buffer. | |
| auto | reference (size_t start=0, size_t length=std::numeric_limits< size_t >::max()) const noexcept -> Buffer |
| Creates a buffer reference. | |
| std::string | hexdump () const noexcept |
| Creates a hexdump representation. | |
| std::string | hexstring () const noexcept |
| Creates a hexdump representation. | |
Private Attributes | |
| Byte * | mBuffer = nullptr |
| The buffer pointer. | |
| size_t | mSize = 0 |
| The buffer size. | |
| size_t | mCapacity = 0 |
| The buffer capacity. | |
| bool | mOwns = true |
| A flag that indicates whether the buffer is owned or not. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Buffer &buffer) |
Represents a secure buffer i.e.
a buffer that protects its memory by doing the following:
The buffer const iterator.
The buffer iterator.
|
noexcept |
Creates a new empty buffer.
|
noexcept |
Creates a new null buffer.
|
explicitnoexcept |
Creates a new buffer with "size" bytes preallocated.
| size | The number of bytes to preallocate |
Creates a new buffer by referecning another raw buffer.
Important: the data is not copied!
| buffer | The buffer |
| size | The buffer size |
| copy | A flag that configures copying |
Creates a new buffer by copying another raw buffer.
| buffer | The buffer |
| size | The buffer size |
Creates a new buffer using a initializer list.
| bytes | The buffer content |
Creates a new buffer by creating a copy of another.
| other | The instance to copy from |
|
noexcept |
Creates a new buffer by moving another.
| other | The instance to move from |
|
noexcept |
Destroys and releases the buffer content.
Appends a buffer to the end of this buffer.
| buffer | The buffer to be appended |
|
inlinenoexcept |
Gets a iterator that points to the beginning of the buffer.
|
inlinenoexcept |
Gets a iterator that points to the begining of the buffer.
Gets a pointer to the raws buffer data.
|
inlinenoexcept |
Gets a pointer to the raws buffer data.
|
inlinenoexcept |
Gets the buffer capacity.
|
inlinenoexcept |
Gets a iterator that points to the beginning of the buffer.
|
inlinenoexcept |
Gets a iterator that points to the end of the buffer.
|
noexcept |
Creates a explicit buffer copy.
Gets a pointer to the raws buffer data.
|
inlinenoexcept |
Gets a pointer to the raws buffer data.
|
inlinenoexcept |
Checks if the buffer is currently empty (i.e.
size is zero)
|
inlinenoexcept |
Gets a iterator that points to the end of the buffer.
|
inlinenoexcept |
Gets a iterator that points to the end of the buffer.
|
noexcept |
Creates a hexdump representation.
|
noexcept |
Creates a hexdump representation.
|
inlineexplicitnoexcept |
Checks if the buffer is valid (i.e.
not null)
|
inlinenoexcept |
Compares a buffer for inequality If either buffer contain the same address and size, retuns false.
If the addresses differ the content is checked for inequality.
| other | the instance to compare to |
Assigns this buffer another buffer's content by moving it.
| other | The instance to move from |
Assigns this buffer a copy of another.
| other | The instance to copy from |
Compares a buffer for equality If either buffer contain the same address and size, retuns true.
If the addresses differ the content is checked for equality.
| other | the instance to compare to |
Accesses a buffer element by its offset.
| offset | The memory offset the access the element at |
offset Accesses a buffer element by its offset.
| offset | The memory offset the access the element at |
offset
|
noexcept |
Transforms a unowned buffer into a owned buffer.
If the buffer is already owned, this call has no effect.
|
inlinenoexcept |
Checks if the buffer is currently owned.
|
noexcept |
Creates a buffer reference.
| start | The starting byte |
| length | The length of the reference |
Reservers at least newCapacity bytes in the buffer.
| newCapacity | The buffers new capacity |
Resizes the buffer to be able to store up-to "newSize" bytes.
| newSize | The new buffer limit |
|
inlinenoexcept |
Gets the number of bytes currently allocated in the buffer.
|
inlinenoexcept |
Checks if the buffer is valid.
Writes buf to the end of the buffer.
| buf | The buffer to be written |
| length | The buffer length |
|
private |
The buffer capacity.
A flag that indicates whether the buffer is owned or not.
|
private |
The buffer size.