Berserk
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Data Class Referencefinal

Generic shared byte data storage. More...

#include <Data.hpp>

Inheritance diagram for Data:
Inheritance graph
[legend]
Collaboration diagram for Data:
Collaboration graph
[legend]

Public Types

using ReleaseProc = std::function< void(void *)>
 

Public Member Functions

BRK_API ~Data () override
 
const void * GetData () const
 
void * GetDataWrite ()
 
size_t GetSize () const
 
bool IsMutable () const
 
void MarkImmutable ()
 
- Public Member Functions inherited from RefCnt
virtual ~RefCnt ()
 
bool IsUnique () const
 
std::int32_t GetRefs () const
 
std::int32_t AddRef () const
 
std::int32_t RelRef () const
 

Static Public Member Functions

static BRK_API Ref< DataMake (const void *data, size_t sizeInBytes)
 
static BRK_API Ref< DataMake (const String &string)
 
static BRK_API Ref< DataMake (size_t sizeInBytes)
 

Protected Member Functions

 Data (size_t size, void *ptr, ReleaseProc releaseProc, bool isMutable)
 
- Protected Member Functions inherited from RefCnt
virtual void Destroy () const
 

Detailed Description

Generic shared byte data storage.

Member Typedef Documentation

◆ ReleaseProc

using Data::ReleaseProc = std::function<void(void *)>

Constructor & Destructor Documentation

◆ ~Data()

Data::~Data ( )
override

◆ Data()

BRK_NS_BEGIN Data::Data ( size_t  size,
void *  ptr,
ReleaseProc  releaseProc,
bool  isMutable 
)
protected

[Internal Usage] Creates data instance

Member Function Documentation

◆ GetData()

const void* Data::GetData ( ) const
inline
Returns
Pointer to the read-only memory with data

◆ GetDataWrite()

void* Data::GetDataWrite ( )
inline
Returns
Pointer to the memory with data

◆ GetSize()

size_t Data::GetSize ( ) const
inline
Returns
Size of the memory data

◆ IsMutable()

bool Data::IsMutable ( ) const
inline
Returns
True if this data buffer is mutable

◆ Make() [1/3]

Ref< Data > Data::Make ( const String string)
static

Makes new data from string characters. Uses system malloc for internal data storage allocation.

Parameters
stringString to make data from
Returns
Created data instance

◆ Make() [2/3]

Ref< Data > Data::Make ( const void *  data,
size_t  sizeInBytes 
)
static

Makes new data from provided data buffer. Uses system malloc for internal data storage allocation.

Parameters
dataPointer to data to copy into buffer
sizeInBytesSize in bytes of the buffer
Returns
Created data instance

◆ Make() [3/3]

Ref< Data > Data::Make ( size_t  sizeInBytes)
static

Makes new data with specified size. Use get data function to retrieve writable memory pointer. Uses system malloc for internal data storage allocation.

Parameters
sizeInBytesSize in bytes of the data buffer
Returns
Created data instance

◆ MarkImmutable()

void Data::MarkImmutable ( )
inline

Lock data for mutation. Now it is immutable.


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