MVault 0.0.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mvlt::DataSaver Class Reference

A class for storing any type of data. More...

#include <DataSaver.h>

Public Member Functions

 DataSaver () noexcept
 Default constructor.
 
 DataSaver (const DataSaver &dataSaver) noexcept
 Copy constructor.
 
template<class T >
 DataSaver (const T &data) noexcept
 A template constructor that accepts a variable to store inside DataSaver.
 
template<class T , class F >
 DataSaver (const T &data, F &&customDeleteFunc) noexcept
 A template constructor that accepts a variable and a function to delete a variable.
 
DataSaveroperator= (const DataSaver &dataSaver) noexcept
 Assignment operator.
 
template<class T >
void SetData (const T &data) noexcept
 Template method to save data inside DataSaver.
 
bool SetDataFromString (const std::string &data) noexcept
 A method for saving data from a string to a DataStorage.
 
template<class T , class F >
void SetData (const T &data, F &&customDeleteFunc) noexcept
 Template method to save data and custom delete function inside DataSaver.
 
template<class T >
bool GetData (T &data) const noexcept
 Template method to get data from DataSaver.
 
void ResetData () noexcept
 Resets the object to its initial state.
 
void Swap (DataSaver &dataSaver) noexcept
 Swap data between 2 DataSavers.
 
std::string Str () const noexcept
 A method for getting a string that represents data inside a class object.
 
std::type_index GetDataType () const noexcept
 A method for getting the type of saved data.
 
 ~DataSaver () noexcept
 Default destructor.
 

Detailed Description

A class for storing any type of data.

If a pointer is stored in a class, then you can set a function to automatically clear this pointer when an object of the class is destroyed. By default, it stores the void type.

Warning
The class cannot store с-arrays

Constructor & Destructor Documentation

◆ DataSaver() [1/3]

mvlt::DataSaver::DataSaver ( const DataSaver dataSaver)
noexcept

Copy constructor.

Parameters
[in]dataSaverobject to be copied

◆ DataSaver() [2/3]

template<class T >
mvlt::DataSaver::DataSaver ( const T data)
inlinenoexcept

A template constructor that accepts a variable to store inside DataSaver.

Template Parameters
<T>Any type of data except for c arrays
Parameters
[in]datadata to be stored inside DataSaver

◆ DataSaver() [3/3]

template<class T , class F >
mvlt::DataSaver::DataSaver ( const T data,
F &&  customDeleteFunc 
)
inlinenoexcept

A template constructor that accepts a variable and a function to delete a variable.

Template Parameters
<T>Any type of data except for c arrays
<F>Function pointer or lambda function

The constructor allows you to set a function to delete data, which can be convenient when storing pointers, when the pointer type may be unknown, but it must be deleted.

Parameters
[in]datadata to be stored inside the class
[in]customDeleteFuncfunction to delete data

Member Function Documentation

◆ GetData()

template<class T >
bool mvlt::DataSaver::GetData ( T data) const
inlinenoexcept

Template method to get data from DataSaver.

Template Parameters
<T>Any type of data except for c arrays
Parameters
[out]datathe ref to which the data will be written
Returns
return the true if it successfully recorded the data. If there was no data or they were of a different type it will return false

◆ GetDataType()

std::type_index mvlt::DataSaver::GetDataType ( ) const
noexcept

A method for getting the type of saved data.

Returns
std::type_index object with saved data type

◆ operator=()

DataSaver & mvlt::DataSaver::operator= ( const DataSaver dataSaver)
noexcept

Assignment operator.

Parameters
[in]dataSaverobject to be copied
Returns
returns a new object, with data from dataSaver

◆ ResetData()

void mvlt::DataSaver::ResetData ( )
noexcept

Resets the object to its initial state.

If deleteFunc was set, it will be called

◆ SetData() [1/2]

template<class T >
void mvlt::DataSaver::SetData ( const T data)
inlinenoexcept

Template method to save data inside DataSaver.

Template Parameters
<T>Any type of data except for c arrays
Parameters
[in]datadata to be stored inside the class

◆ SetData() [2/2]

template<class T , class F >
void mvlt::DataSaver::SetData ( const T data,
F &&  customDeleteFunc 
)
inlinenoexcept

Template method to save data and custom delete function inside DataSaver.

Template Parameters
<T>Any type of data except for c arrays
<F>Function pointer or lambda function
Parameters
[in]datadata to be stored inside the class
[in]customDeleteFuncfunction to delete data

◆ SetDataFromString()

bool mvlt::DataSaver::SetDataFromString ( const std::string &  data)
noexcept

A method for saving data from a string to a DataStorage.

Parameters
[in]dataa string with data

◆ Str()

std::string mvlt::DataSaver::Str ( ) const
noexcept

A method for getting a string that represents data inside a class object.

Used ToString function.

Returns
A string of data

◆ Swap()

void mvlt::DataSaver::Swap ( DataSaver dataSaver)
noexcept

Swap data between 2 DataSavers.

Parameters
[in,out]dataSaverdataSaver from where the data will be copied to this and where the data from this will be written

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