Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::Buffer Struct Reference

A simple container for a raw memory buffer. More...

#include <Buffer.h>

Public Member Functions

 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 Public Member Functions

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.

Public Attributes

u8Data = nullptr
 Pointer to the buffer's data.
u64 Size = 0
 Size of the buffer.

Detailed Description

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:

  1. Allocate a buffer with a specific size using Allocate(size).
  2. Copy data into a new buffer using Copy().
  3. Release the buffer when done using Release().

Constructor & Destructor Documentation

◆ 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
sizeSize of the buffer to allocate.

◆ Buffer() [3/3]

Raven::Buffer::Buffer ( const Buffer & )
default

Copy constructor. This copies the data from another buffer.

Member Function Documentation

◆ Allocate()

void Raven::Buffer::Allocate ( u64 size)
inline

Allocates memory for the buffer with the specified size.

Parameters
sizeThe 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
TThe type to cast to.
Returns
A pointer to the buffer's data as type T.

◆ Copy() [1/2]

Buffer Raven::Buffer::Copy ( Buffer other)
inlinestatic

Static function that creates a buffer by copying another buffer.

Parameters
otherThe buffer to copy.
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
dataPointer to the raw data to copy.
sizeThe 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.

Member Data Documentation

◆ Data

u8* Raven::Buffer::Data = nullptr

Pointer to the buffer's data.

◆ Size

u64 Raven::Buffer::Size = 0

Size of the buffer.


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