MVault 0.0.1
|
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. | |
DataSaver & | operator= (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. | |
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.
Copy constructor.
[in] | dataSaver | object to be copied |
A template constructor that accepts a variable and a function to delete a variable.
<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.
[in] | data | data to be stored inside the class |
[in] | customDeleteFunc | function to delete data |
Template method to get data from DataSaver.
<T> | Any type of data except for c arrays |
[out] | data | the ref to which the data will be written |
|
noexcept |
A method for getting the type of saved data.
Assignment operator.
[in] | dataSaver | object to be copied |
|
noexcept |
Resets the object to its initial state.
If deleteFunc was set, it will be called
Template method to save data inside DataSaver.
<T> | Any type of data except for c arrays |
[in] | data | data to be stored inside the class |
Template method to save data and custom delete function inside DataSaver.
<T> | Any type of data except for c arrays |
<F> | Function pointer or lambda function |
[in] | data | data to be stored inside the class |
[in] | customDeleteFunc | function to delete data |
A method for saving data from a string to a DataStorage.
[in] | data | a string with data |
|
noexcept |
A method for getting a string that represents data inside a class object.
Used ToString function.
Swap data between 2 DataSavers.
[in,out] | dataSaver | dataSaver from where the data will be copied to this and where the data from this will be written |