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

A class that provides access to data inside Vault. More...

#include <VaultRecordRef.h>

Public Member Functions

 VaultRecordRef () noexcept
 Default constructor.
 
 VaultRecordRef (VaultRecord *vaultRecord, Vault *vlt) noexcept
 Constructor.
 
 VaultRecordRef (const VaultRecordRef &other) noexcept
 Copy constructor.
 
VaultRecordRefoperator= (const VaultRecordRef &other) noexcept
 Assignment operator.
 
bool operator== (const VaultRecordRef &other) const noexcept
 Comparison operator.
 
std::string GetRecordUniqueId () const noexcept
 A method for obtaining a unique record identifier.
 
template<class T >
VaultOperationResult SetData (const std::string &key, const T &data) noexcept
 Method for updating data inside Vault.
 
VaultOperationResult SetData (const std::vector< std::pair< std::string, VaultParamInput > > &params) noexcept
 Method for updating data inside Vault.
 
template<class T >
VaultOperationResult GetData (const std::string &key, T &data) const noexcept
 A method for getting data using a key.
 
VaultOperationResult GetDataAsString (const std::string &key, std::string &str) const noexcept
 Method for getting data converted to string from a container using a key.
 
bool IsValid () const noexcept
 A function to check the validity of a class object.
 
bool IsKeyExist (const std::string &key) const noexcept
 The method for getting a default key value.
 
std::vector< std::string > GetKeys () const noexcept
 The method for getting all the keys.
 
void PrintRecord () const noexcept
 A method for displaying VaultRecordRef content on the screen.
 
void Reset () noexcept
 A method for decoupling a class object from record. Reset class object to default state.
 
 ~VaultRecordRef () noexcept
 Default destructor.
 

Public Attributes

friend Vault
 Making the Vault class friendly so that it has access to the internal members of the VaultRecordRef class.
 
friend VaultRecordSet
 Making the VaultRecordSet class friendly so that it has access to the internal members of the VaultRecordRef class.
 

Detailed Description

A class that provides access to data inside Vault.

This class works as a reference to the data inside the Vault, you can use it to change the data inside the Vault. If two objects of the class point to the same VaultRecord inside the Vault, then when the data in one object changes, the data in the other object will also change. If the record pointed to by an object of this class is deleted, the isValid function will return false, and any attempt to access or change the data will be ignored.

Constructor & Destructor Documentation

◆ VaultRecordRef() [1/2]

mvlt::VaultRecordRef::VaultRecordRef ( VaultRecord vaultRecord,
Vault vlt 
)
noexcept

Constructor.

Simply call SetRecord method

Parameters
[in]vaultRecordA pointer to the VaultRecord referenced by the class object VaultRecordRef
[in]vltA pointer to Vault

◆ VaultRecordRef() [2/2]

mvlt::VaultRecordRef::VaultRecordRef ( const VaultRecordRef other)
noexcept

Copy constructor.

Parameters
[in]otherother VaultRecordRef object

Member Function Documentation

◆ GetData()

template<class T >
VaultOperationResult mvlt::VaultRecordRef::GetData ( const std::string &  key,
T data 
) const
noexcept

A method for getting data using a key.

Template Parameters
<T>Any type of data except for c arrays
Parameters
[in]keythe key whose value should be obtained
[in]datareference to record the received data
Returns
VaultOperationResult object with GetData result.

◆ GetDataAsString()

VaultOperationResult mvlt::VaultRecordRef::GetDataAsString ( const std::string &  key,
std::string &  str 
) const
noexcept

Method for getting data converted to string from a container using a key.

Parameters
[in]keykey for getting data
[out]stra reference to string to write data from the container there. If the data was not found, then nothing will be written to the str

It uses the ToString function inside. If it is not defined for the type, then the str will be an empty string.

Returns
VaultOperationResult object with GetDataAsString result.

◆ GetKeys()

std::vector< std::string > mvlt::VaultRecordRef::GetKeys ( ) const
noexcept

The method for getting all the keys.

If the record is not valid, it will return an empty vector

Returns
vector with keys

◆ GetRecordUniqueId()

std::string mvlt::VaultRecordRef::GetRecordUniqueId ( ) const
noexcept

A method for obtaining a unique record identifier.

Important. Two VaultRecordRef objects pointing to the same record will return the same value. Invalid record will return null

Returns
the unique identifier of the record

◆ IsKeyExist()

bool mvlt::VaultRecordRef::IsKeyExist ( const std::string &  key) const
noexcept

The method for getting a default key value.

Parameters
[in]keythe name of the key to search for
Returns
returns true if the key was found otherwise returns false

◆ IsValid()

bool mvlt::VaultRecordRef::IsValid ( ) const
noexcept

A function to check the validity of a class object.

An object may no longer be valid if the record it refers to has been deleted

Returns
returns true if the object is valid, otherwise false

◆ operator=()

VaultRecordRef & mvlt::VaultRecordRef::operator= ( const VaultRecordRef other)
noexcept

Assignment operator.

Parameters
[in]otherother VaultRecordRef object

◆ operator==()

bool mvlt::VaultRecordRef::operator== ( const VaultRecordRef other) const
noexcept

Comparison operator.

Parameters
[in]otherthe object to compare with
Returns
true if the objects are equal, otherwise false. Two invalid objects are equal

◆ SetData() [1/2]

template<class T >
VaultOperationResult mvlt::VaultRecordRef::SetData ( const std::string &  key,
const T data 
)
noexcept

Method for updating data inside Vault.

Template Parameters
<T>Any type of data except for c arrays

Using this method, you can change the values inside the VaultRecord inside the Vault

Parameters
[in]keythe key whose value needs to be changed
[in]datanew key data value
Returns
VaultOperationResult object with GetData result.

◆ SetData() [2/2]

VaultOperationResult mvlt::VaultRecordRef::SetData ( const std::vector< std::pair< std::string, VaultParamInput > > &  params)
noexcept

Method for updating data inside Vault.

Using this method, you can change the values inside the VaultRecord inside the Vault.
See Vault::CreateRecord(std::vector<std::pair<std::string, VaultParamInput>>&& params) for more information

Parameters
[in]paramsa vector of pairs with data to be put in the Vault
Returns
If one of the parameters is incorrect, it returns an error when setting this parameter, and all subsequent parameters will not be set

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