A simple container for a raw memory buffer.
More...
#include <Buffer.h>
|
| | Buffer ()=default |
| | Default constructor, initializes an empty buffer.
|
| | Buffer (u64 size) |
| | Constructor that allocates a buffer of the given size.
|
| | Buffer (const Buffer &)=default |
| | Copy constructor. This copies the data from another buffer.
|
| void | Allocate (u64 size) |
| | Allocates memory for the buffer with the specified size.
|
| void | Release () |
| | Releases the buffer's memory and resets the data pointer and size.
|
| template<typename T> |
| T * | As () |
| | Casts the buffer's raw data to a specific type.
|
| | operator bool () const |
| | Converts the buffer to a boolean value.
|
|
| static Buffer | Copy (Buffer other) |
| | Static function that creates a buffer by copying another buffer.
|
| static Buffer | Copy (const void *data, u64 size) |
| | Static function that creates a buffer by copying raw data.
|
|
| u8 * | Data = nullptr |
| | Pointer to the buffer's data.
|
| u64 | Size = 0 |
| | Size of the buffer.
|
A simple container for a raw memory buffer.
This struct represents a raw memory buffer with a size and a pointer to the data. It provides utilities for memory allocation, deallocation, and casting to other types.
Typical usage:
- Allocate a buffer with a specific size using Allocate(size).
- Copy data into a new buffer using Copy().
- Release the buffer when done using Release().
◆ Buffer() [1/3]
| Raven::Buffer::Buffer |
( |
| ) |
|
|
default |
Default constructor, initializes an empty buffer.
◆ Buffer() [2/3]
| Raven::Buffer::Buffer |
( |
u64 | size | ) |
|
|
inlineexplicit |
Constructor that allocates a buffer of the given size.
- Parameters
-
| size | Size of the buffer to allocate. |
◆ Buffer() [3/3]
| Raven::Buffer::Buffer |
( |
const Buffer & | | ) |
|
|
default |
Copy constructor. This copies the data from another buffer.
◆ Allocate()
| void Raven::Buffer::Allocate |
( |
u64 | size | ) |
|
|
inline |
Allocates memory for the buffer with the specified size.
- Parameters
-
| size | The size of the buffer to allocate. |
◆ As()
template<typename T>
| T * Raven::Buffer::As |
( |
| ) |
|
|
inline |
Casts the buffer's raw data to a specific type.
- Template Parameters
-
- Returns
- A pointer to the buffer's data as type T.
◆ Copy() [1/2]
Static function that creates a buffer by copying another buffer.
- Parameters
-
- Returns
- A new buffer that contains the same data as the other buffer.
◆ Copy() [2/2]
| Buffer Raven::Buffer::Copy |
( |
const void * | data, |
|
|
u64 | size ) |
|
inlinestatic |
Static function that creates a buffer by copying raw data.
- Parameters
-
| data | Pointer to the raw data to copy. |
| size | The size of the data to copy. |
- Returns
- A new buffer containing the copied data.
◆ operator bool()
| Raven::Buffer::operator bool |
( |
| ) |
const |
|
inlineexplicit |
Converts the buffer to a boolean value.
- Returns
- true if the buffer contains data, false otherwise.
◆ Release()
| void Raven::Buffer::Release |
( |
| ) |
|
|
inline |
Releases the buffer's memory and resets the data pointer and size.
◆ Data
| u8* Raven::Buffer::Data = nullptr |
Pointer to the buffer's data.
◆ Size
| u64 Raven::Buffer::Size = 0 |
The documentation for this struct was generated from the following file: