4#include "VaultRecordSet.h"
6#include "VaultRecord.hpp"
7#include "VaultParamInput.hpp"
20 res.RequestedType =
typeid(
T);
34 res.IsOperationSuccess =
false;
40 if(!GetKeyType(
key,
res.SavedType))
42 res.IsOperationSuccess =
false;
48 if (
res.SavedType !=
res.RequestedType)
50 res.IsOperationSuccess =
false;
69 res.IsOperationSuccess =
false;
113 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
122 res.IsOperationSuccess =
true;
138 res.RequestedType =
typeid(
T);
144 if(!GetKeyType(
key,
res.SavedType))
146 res.IsOperationSuccess =
false;
152 if (
res.SavedType !=
res.RequestedType)
154 res.IsOperationSuccess =
false;
205 case VaultRequestType::GreaterOrEqual:
210 case VaultRequestType::Greater:
215 case VaultRequestType::Less:
220 case VaultRequestType::LessOrEqual:
225 case VaultRequestType::Interval:
239 case VaultRequestType::Equal:
240 case VaultRequestType::Or:
241 case VaultRequestType::And:
265 res.SavedType =
res.RequestedType;
266 res.IsOperationSuccess =
true;
284 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
332 res.RequestedType =
typeid(
T);
339 if (
keyType != KeysTypes.end())
341 res.IsOperationSuccess =
false;
369 res.IsOperationSuccess =
false;
402 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
410 VaultHashMapStructure.EraseData(
key);
411 VaultMapStructure.EraseData(
key);
413 res.IsOperationSuccess =
false;
429 if(VaultDerivedClass == VaultDerivedClasses::VaultBase)
430 KeysOrder.emplace_back(
key);
433 KeysTypes.emplace(
key,
typeid(
T));
462 VaultRecordClearers.emplace(
key, [=]()
482 if ((*pairIt).second ==
record)
494 if ((*pairIt).second ==
record)
524 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
532 set->KeysOrder.emplace_back(
key);
536 res.IsOperationSuccess =
true;
546 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
547 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
548 AddKey<std::string>(\"Key\", \"Value\") or AddKey(\"Key\", std::string(\"Value\"))");
558 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
559 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
560 AddUniqueKey<std::string>(\"Key\")");
578 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
579 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
580 UpdateKey<std::string>(\"Key\", \"Value\") or UpdateKey(\"Key\", std::string(\"Value\"))");
590 std::unordered_map<std::string, std::type_index>::iterator
keyTypeIt = KeysTypes.find(
key);
593 res.IsOperationSuccess =
false;
602 res.IsOperationSuccess =
false;
608 if (UniqueKeys.find(
key) != UniqueKeys.end())
611 res.IsOperationSuccess =
false;
619 res.SavedType =
res.RequestedType;
629 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value.");
633 res.RequestedType =
typeid(
T);
639 if(!GetKeyType(
key,
res.SavedType))
641 res.IsOperationSuccess =
false;
647 if (
res.SavedType !=
res.RequestedType)
649 res.IsOperationSuccess =
false;
655 if (UniqueKeys.find(
key) != UniqueKeys.end())
657 res.IsOperationSuccess =
false;
664 res.IsOperationSuccess =
true;
666 res.SavedType =
res.RequestedType;
676 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
677 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
678 GetRecord<std::string>(\"Key\", \"Value\") or GetRecord(\"Key\", std::string(\"Value\"))");
683 res.RequestedType =
typeid(
T);
689 if(!GetKeyType(
key,
res.SavedType))
691 res.IsOperationSuccess =
false;
697 if (
res.SavedType !=
res.RequestedType)
699 res.IsOperationSuccess =
false;
715 res.IsOperationSuccess =
true;
721 res.IsOperationSuccess =
false;
733 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
734 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
735 GetRecords<std::string>(\"Key\", \"Value\") or GetRecords(\"Key\", std::string(\"Value\"))");
740 res.RequestedType =
typeid(
T);
748 if(!GetKeyType(
key,
res.SavedType))
750 res.IsOperationSuccess =
false;
756 if (
res.SavedType !=
res.RequestedType)
758 res.IsOperationSuccess =
false;
781 res.IsOperationSuccess =
true;
786 res.IsOperationSuccess =
false;
799 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
800 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
801 RequestEqual<std::string>(\"Key\", \"Value\") or RequestEqual(\"Key\", std::string(\"Value\"))");
812 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
813 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
814 RequestGreater<std::string>(\"Key\", \"Value\") or RequestGreater(\"Key\", std::string(\"Value\"))");
825 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
826 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
827 RequestGreaterOrEqual<std::string>(\"Key\", \"Value\") or RequestGreaterOrEqual(\"Key\", std::string(\"Value\"))");
838 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
839 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
840 RequestLess<std::string>(\"Key\", \"Value\") or RequestLess(\"Key\", std::string(\"Value\"))");
851 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
852 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
853 RequestLessOrEqual<std::string>(\"Key\", \"Value\") or RequestLessOrEqual(\"Key\", std::string(\"Value\"))");
865 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
866 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
867 RequestInterval<std::string>(\"Key\", \"Value\") or RequestInterval(\"Key\", std::string(\"Value\"))");
874 template <VaultRequestType Type>
880 res.IsOperationSuccess =
true;
942 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
943 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
944 EraseRecord<std::string>(\"Key\", \"Value\") or EraseRecord(\"Key\", std::string(\"Value\"))");
949 res.RequestedType =
typeid(
T);
955 if(!GetKeyType(
key,
res.SavedType))
957 res.IsOperationSuccess =
false;
963 if (
res.SavedType !=
res.RequestedType)
965 res.IsOperationSuccess =
false;
982 for (
auto&
eraser : VaultRecordErasers)
989 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
991 tmpRec->RemoveFromDependentSets();
995 res.IsOperationSuccess =
true;
1000 res.IsOperationSuccess =
false;
1012 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
1013 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
1014 EraseRecords<std::string>(\"Key\", \"Value\") or EraseRecords(\"Key\", std::string(\"Value\"))");
1019 res.RequestedType =
typeid(
T);
1025 if(!GetKeyType(
key,
res.SavedType))
1027 res.IsOperationSuccess =
false;
1033 if (
res.SavedType !=
res.RequestedType)
1035 res.IsOperationSuccess =
false;
1050 res.IsOperationSuccess =
true;
1063 for (
auto&
eraser : VaultRecordErasers)
1066 RecordsSet.erase(
tmpRec);
1070 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
1072 tmpRec->RemoveFromDependentSets();
1083 res.IsOperationSuccess =
false;
Iterator class for all library maps.
Definition Map.h:18
A class for storing data with the ability to quickly search for a variety of different keys of any ty...
Definition Vault.h:35
bool EraseRecord(const VaultRecordRef &recordRefToErase) noexcept
Method for deleting a record from a Vault.
Definition Vault.cpp:626
VaultOperationResult RequestLessOrEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat=DefaultRequestPredicat) const noexcept
A method for getting all records that have a value less than or equal to keyValue stored by the key k...
Definition Vault.hpp:846
VaultOperationResult GetKeyValue(const std::string &key, T &defaultKeyValue) const noexcept
The method for getting a default key value.
Definition Vault.hpp:625
VaultOperationResult RequestRecords(const VaultRequestType &requestType, const std::string &key, const T &beginKeyValue, const T &endKeyValue, VaultRecordSet &vaultRecordSet, const bool &isIncludeBeginKeyValue, const bool &isIncludeEndKeyValue, const std::size_t &amountOfRecords, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat) const noexcept
The method for getting the result of the request.
Definition Vault.hpp:272
VaultOperationResult SetDataToRecord(VaultRecord *dataRecord, const std::string &key, const T &data) noexcept
Method for setting a new value in VaultRecord and Vault.
Definition Vault.hpp:13
VaultOperationResult AddKey(const std::string &key, const T &defaultKeyValue, const bool &isUniqueKey, const bool &isUniqueKeyWithoutLambda, const std::function< T(const std::size_t &counter, const VaultRecordRef &ref)> &uniqueKeyFunction) noexcept
Template method to add new key with default value to Vault.
Definition Vault.hpp:325
VaultOperationResult GetRecord(const std::string &key, const T &keyValue, VaultRecordRef &vaultRecordRef) const noexcept
The method for getting a reference to the data inside Vault.
Definition Vault.hpp:672
VaultOperationResult RequestRecordsSet(const VaultRequestType &requestType, const std::string &key, const T &beginKeyValue, const T &endKeyValue, std::unordered_set< VaultRecord * > &recordsSet, const bool &isIncludeBeginKeyValue, const bool &isIncludeEndKeyValue, const std::size_t &amountOfRecords, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat) const noexcept
The method for getting the result of the request in the std::set.
Definition Vault.hpp:129
VaultOperationResult GetRecords(const std::string &key, const T &keyValue, std::vector< VaultRecordRef > &recordsRefs, const std::size_t &amountOfRecords=-1) const noexcept
The method for getting a vector of references to the data inside Vault.
Definition Vault.hpp:729
VaultDerivedClasses VaultDerivedClass
A variable for storing the object type in the Vault inheritance tree.
Definition Vault.h:107
VaultOperationResult RequestEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat=DefaultRequestPredicat) const noexcept
A method for getting all records that have a value equal to keyValue stored by the key key.
Definition Vault.hpp:794
VaultOperationResult RequestGreater(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat=DefaultRequestPredicat) const noexcept
A method for getting all records that have a value greater than keyValue stored by the key key.
Definition Vault.hpp:807
VaultOperationResult RequestLess(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat=DefaultRequestPredicat) const noexcept
A method for getting all records that have a value less than keyValue stored by the key key.
Definition Vault.hpp:833
VaultOperationResult RequestInterval(const std::string &key, const T &beginKeyValue, const T &endKeyValue, VaultRecordSet &vaultRecordSet, const bool &isIncludeBeginKeyValue=true, const bool &isIncludeEndKeyValue=true, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat=DefaultRequestPredicat) const noexcept
The method for getting the result of the request.
Definition Vault.hpp:859
@ VaultBase
Vault class itself.
std::unordered_set< VaultRecordSet * > RecordSetsSet
Unordered set with all VaultRecordSet pointers.
Definition Vault.h:113
VaultOperationResult Request(const VaultRequest< Type > &request, VaultRecordSet &vaultRecordSet) const
A method for complex requests.
Definition Vault.hpp:875
VaultOperationResult RequestGreaterOrEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &ref)> &requestPredicat=DefaultRequestPredicat) const noexcept
A method for getting all records that have a value greater than or equal to keyValue stored by the ke...
Definition Vault.hpp:820
VaultOperationResult EraseRecords(const std::string &key, const T &keyValue, const std::size_t &amountOfRecords=-1) noexcept
The method for erase records using key and value.
Definition Vault.hpp:1008
VaultOperationResult UpdateKey(const std::string &key, const T &defaultKeyValue) noexcept
Template method to update default key value.
Definition Vault.hpp:574
VaultOperationResult AddUniqueKey(const std::string &key) noexcept
Template method to add new unique key to Vault.
Definition Vault.hpp:554
A class for storing data inside Vault.
Definition VaultRecord.h:18
A class that provides access to data inside Vault.
Definition VaultRecordRef.h:21
A class for storing query results.
Definition VaultRecordSet.h:14
@ Success
This value is returned when the request was completely successful.
@ DataRecordNotValid
This code is returned when data is requested from the VaultRecordRef and the record it refers to is n...
@ UniqueKeyValueAlredyInSet
This value is returned when the key was found, the requested type and the saved type are equal,...
@ WrongKey
This code is returned when the requested key has not been found.
@ WrongValue
This value is returned when the key was found, the requested type and the saved type are equal,...
@ UniqueKey
This code is returned when trying to update default value in an unique key.
@ TryToAddUniqueKeyInNonEmptyVaultWithoutLambda
This code is returned when trying to add unique key without lamda in non-empty vault.
@ DuplicateKey
This code is returned when trying to add key which alredy in vault.
@ WrongType
This code is returned when the requested type does not match the saved type.
Structure for storing the results of MVault operations.
Definition VaultOperationResult.h:44