Nebula
Loading...
Searching...
No Matches
Util::Blob Class Reference

#include <blob.h>

Detailed Description

The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied, compared and hashed.

Public Member Functions

void * operator new (size_t s)
 override new operator
 
void operator delete (void *ptr)
 override delete operator
 
 Blob ()
 default constructor
 
 Blob (std::nullptr_t t)
 nullptr constructor
 
 Blob (const void *ptr, size_t size)
 constructor
 
 Blob (size_t size)
 reserve N bytes
 
 Blob (const Blob &rhs)
 copy constructor
 
 Blob (Blob &&rhs) noexcept
 move constructor
 
 ~Blob ()
 destructor
 
void operator= (const Blob &rhs)
 assignment operator
 
void operator= (Blob &&rhs) noexcept
 move assignment operator
 
bool operator== (const Blob &rhs) const
 equality operator
 
bool operator!= (const Blob &rhs) const
 inequality operator
 
bool operator> (const Blob &rhs) const
 greater operator
 
bool operator< (const Blob &rhs) const
 less operator
 
bool operator>= (const Blob &rhs) const
 greater-equal operator
 
bool operator<= (const Blob &rhs) const
 less-eqial operator
 
bool IsValid () const
 return true if the blob contains data
 
void Reserve (size_t size)
 reserve N bytes
 
void Trim (size_t size)
 trim the size member (without re-allocating!)
 
void Set (const void *ptr, size_t size)
 set blob contents
 
void SetFromBase64 (const void *ptr, size_t size)
 set from base64 enconded
 
void SetFromFile (const IO::URI &uri)
 set from file
 
void SetChunk (const void *from, size_t size, size_t internalOffset)
 set chunk contents. Will allocate more memory if necessary.
 
void * GetPtr () const
 get blob ptr
 
size_t Size () const
 get blob size
 
uint32_t HashCode () const
 get a hash code (compatible with Util::HashTable)
 
Util::Blob GetBase64 () const
 get as base64 encoded
 

Static Public Member Functions

static void Setup ()
 static Setup method, called by SysFunc::Setup()
 
static void Shutdown ()
 static Shutdown method called by SysFunc::Exit
 

Private Member Functions

void Delete ()
 delete content
 
void Allocate (size_t size)
 allocate internal buffer
 
void Copy (const void *ptr, size_t size)
 copy content
 
void GrowTo (size_t size)
 Increases allocated size without deleting existing data (reallocate and memcopy).
 
int BinaryCompare (const Blob &rhs) const
 do a binary comparison between this and other blob
 

Private Attributes

void * ptr = nullptr
 
size_t size = 0
 
size_t allocSize = 0
 

Static Private Attributes

static Memory::HeapDataHeap = 0
 

Constructor & Destructor Documentation

◆ Blob() [1/6]

Util::Blob::Blob ( )
inline

default constructor

◆ Blob() [2/6]

Util::Blob::Blob ( std::nullptr_t t)
inline

nullptr constructor

◆ Blob() [3/6]

Util::Blob::Blob ( const void * ptr,
size_t size )
inline

constructor

◆ Blob() [4/6]

Util::Blob::Blob ( size_t size)
inline

reserve N bytes

◆ Blob() [5/6]

Util::Blob::Blob ( const Blob & rhs)
inline

copy constructor

◆ Blob() [6/6]

Util::Blob::Blob ( Blob && rhs)
inlinenoexcept

move constructor

◆ ~Blob()

Util::Blob::~Blob ( )
inline

destructor

Member Function Documentation

◆ Allocate()

void Util::Blob::Allocate ( size_t size)
inlineprivate

allocate internal buffer

◆ BinaryCompare()

int Util::Blob::BinaryCompare ( const Blob & rhs) const
private

do a binary comparison between this and other blob

Like strcmp(), but checks the blob contents.

◆ Copy()

void Util::Blob::Copy ( const void * ptr,
size_t size )
inlineprivate

copy content

◆ Delete()

void Util::Blob::Delete ( )
inlineprivate

delete content

◆ GetBase64()

Util::Blob Util::Blob::GetBase64 ( ) const

get as base64 encoded

creates a base64 copy blob

◆ GetPtr()

void * Util::Blob::GetPtr ( ) const
inline

get blob ptr

◆ GrowTo()

void Util::Blob::GrowTo ( size_t size)
inlineprivate

Increases allocated size without deleting existing data (reallocate and memcopy).

◆ HashCode()

uint32_t Util::Blob::HashCode ( ) const
inline

get a hash code (compatible with Util::HashTable)

◆ IsValid()

bool Util::Blob::IsValid ( ) const
inline

return true if the blob contains data

◆ operator delete()

__forceinline void Util::Blob::operator delete ( void * ptr)

override delete operator

◆ operator new()

__forceinline void * Util::Blob::operator new ( size_t s)

override new operator

◆ operator!=()

bool Util::Blob::operator!= ( const Blob & rhs) const
inline

inequality operator

◆ operator<()

bool Util::Blob::operator< ( const Blob & rhs) const
inline

less operator

◆ operator<=()

bool Util::Blob::operator<= ( const Blob & rhs) const
inline

less-eqial operator

◆ operator=() [1/2]

void Util::Blob::operator= ( Blob && rhs)
inlinenoexcept

move assignment operator

◆ operator=() [2/2]

void Util::Blob::operator= ( const Blob & rhs)
inline

assignment operator

◆ operator==()

bool Util::Blob::operator== ( const Blob & rhs) const
inline

equality operator

◆ operator>()

bool Util::Blob::operator> ( const Blob & rhs) const
inline

greater operator

◆ operator>=()

bool Util::Blob::operator>= ( const Blob & rhs) const
inline

greater-equal operator

◆ Reserve()

void Util::Blob::Reserve ( size_t size)
inline

reserve N bytes

◆ Set()

void Util::Blob::Set ( const void * ptr,
size_t size )
inline

set blob contents

◆ SetChunk()

void Util::Blob::SetChunk ( const void * from,
size_t size,
size_t internalOffset )
inline

set chunk contents. Will allocate more memory if necessary.

◆ SetFromBase64()

void Util::Blob::SetFromBase64 ( const void * ptr,
size_t size )

set from base64 enconded

decodes a base64 buffer and stores it inside

◆ SetFromFile()

void Util::Blob::SetFromFile ( const IO::URI & uri)

set from file

loads binary from file

◆ Setup()

void Util::Blob::Setup ( )
inlinestatic

static Setup method, called by SysFunc::Setup()

◆ Shutdown()

void Util::Blob::Shutdown ( )
inlinestatic

static Shutdown method called by SysFunc::Exit

◆ Size()

size_t Util::Blob::Size ( ) const
inline

get blob size

◆ Trim()

void Util::Blob::Trim ( size_t size)
inline

trim the size member (without re-allocating!)

Member Data Documentation

◆ allocSize

size_t Util::Blob::allocSize = 0
private

◆ DataHeap

Memory::Heap * Util::Blob::DataHeap = 0
staticprivate

◆ ptr

void* Util::Blob::ptr = nullptr
private

◆ size

size_t Util::Blob::size = 0
private

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