4#include "VaultRecordSet.h"
6#include "VaultRecord.hpp"
7#include "VaultParamInput.hpp"
18 res.RequestedType =
typeid(
T);
32 res.IsOperationSuccess =
false;
38 if(!GetKeyType(
key,
res.SavedType))
40 res.IsOperationSuccess =
false;
46 if (
res.SavedType !=
res.RequestedType)
48 res.IsOperationSuccess =
false;
102 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
111 res.IsOperationSuccess =
true;
125 res.RequestedType =
typeid(
T);
131 if(!GetKeyType(
key,
res.SavedType))
133 res.IsOperationSuccess =
false;
139 if (
res.SavedType !=
res.RequestedType)
141 res.IsOperationSuccess =
false;
202 if ((*TtoVaultRecordMapIt).first != (*startIt).first)
226 while(
endIt != (*TtoVaultRecordMap).Begin() && (*endIt).first ==
endKeyValue)
238 case VaultRequestType::GreaterOrEqual:
243 case VaultRequestType::Greater:
248 case VaultRequestType::Less:
253 case VaultRequestType::LessOrEqual:
258 case VaultRequestType::Interval:
272 case VaultRequestType::Equal:
273 case VaultRequestType::Or:
274 case VaultRequestType::And:
297 res.SavedType =
res.RequestedType;
298 res.IsOperationSuccess =
true;
314 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
360 res.RequestedType =
typeid(
T);
366 if (KeysTypes.find(
key) != KeysTypes.end())
368 res.IsOperationSuccess =
false;
395 res.IsOperationSuccess =
false;
428 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
436 VaultHashMapStructure.EraseData(
key);
437 VaultMapStructure.EraseData(
key);
439 res.IsOperationSuccess =
false;
455 if(VaultDerivedClass == VaultDerivedClasses::VaultBase)
456 KeysOrder.emplace_back(
key);
459 KeysTypes.emplace(
key,
typeid(
T));
488 VaultRecordClearers.emplace(
key, [=]()
550 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
558 set->KeysOrder.emplace_back(
key);
562 res.IsOperationSuccess =
true;
570 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
571 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
572 AddKey<std::string>(\"Key\", \"Value\") or AddKey(\"Key\", std::string(\"Value\"))");
580 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
581 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
582 AddUniqueKey<std::string>(\"Key\")");
596 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
597 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
598 UpdateKey<std::string>(\"Key\", \"Value\") or UpdateKey(\"Key\", std::string(\"Value\"))");
608 std::unordered_map<std::string, std::type_index>::iterator
keyTypeIt = KeysTypes.find(
key);
611 res.IsOperationSuccess =
false;
620 res.IsOperationSuccess =
false;
626 if (UniqueKeys.find(
key) != UniqueKeys.end())
629 res.IsOperationSuccess =
false;
643 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value.");
647 res.RequestedType =
typeid(
T);
653 if(!GetKeyType(
key,
res.SavedType))
655 res.IsOperationSuccess =
false;
661 if (
res.SavedType !=
res.RequestedType)
663 res.IsOperationSuccess =
false;
668 for (
auto&
it : UniqueKeys)
670 std::cout <<
it << std::endl;
674 if (UniqueKeys.find(
key) != UniqueKeys.end())
676 res.IsOperationSuccess =
false;
683 res.IsOperationSuccess =
true;
685 res.SavedType =
res.RequestedType;
693 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
694 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
695 GetRecord<std::string>(\"Key\", \"Value\") or GetRecord(\"Key\", std::string(\"Value\"))");
700 res.RequestedType =
typeid(
T);
706 if(!GetKeyType(
key,
res.SavedType))
708 res.IsOperationSuccess =
false;
714 if (
res.SavedType !=
res.RequestedType)
716 res.IsOperationSuccess =
false;
732 res.IsOperationSuccess =
true;
738 res.IsOperationSuccess =
false;
748 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
749 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
750 GetRecords<std::string>(\"Key\", \"Value\") or GetRecords(\"Key\", std::string(\"Value\"))");
755 res.RequestedType =
typeid(
T);
763 if(!GetKeyType(
key,
res.SavedType))
765 res.IsOperationSuccess =
false;
771 if (
res.SavedType !=
res.RequestedType)
773 res.IsOperationSuccess =
false;
798 res.IsOperationSuccess =
false;
809 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
810 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
811 RequestEqual<std::string>(\"Key\", \"Value\") or RequestEqual(\"Key\", std::string(\"Value\"))");
820 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
821 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
822 RequestGreater<std::string>(\"Key\", \"Value\") or RequestGreater(\"Key\", std::string(\"Value\"))");
831 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
832 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
833 RequestGreaterOrEqual<std::string>(\"Key\", \"Value\") or RequestGreaterOrEqual(\"Key\", std::string(\"Value\"))");
842 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
843 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
844 RequestLess<std::string>(\"Key\", \"Value\") or RequestLess(\"Key\", std::string(\"Value\"))");
853 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
854 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
855 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>
878 res.IsOperationSuccess =
true;
938 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
939 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
940 EraseRecord<std::string>(\"Key\", \"Value\") or EraseRecord(\"Key\", std::string(\"Value\"))");
945 res.RequestedType =
typeid(
T);
951 if(!GetKeyType(
key,
res.SavedType))
953 res.IsOperationSuccess =
false;
959 if (
res.SavedType !=
res.RequestedType)
961 res.IsOperationSuccess =
false;
978 for (
auto&
eraser : VaultRecordErasers)
985 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
987 tmpRec->RemoveFromDependentSets();
991 res.IsOperationSuccess =
true;
996 res.IsOperationSuccess =
false;
1006 static_assert(!std::is_array<T>::value,
"It is not possible to use a c array as a key value. \n\
1007 If you want to use a string as a key, you must specialize the function with a string. Like this: \n\
1008 EraseRecords<std::string>(\"Key\", \"Value\") or EraseRecords(\"Key\", std::string(\"Value\"))");
1013 res.RequestedType =
typeid(
T);
1019 if(!GetKeyType(
key,
res.SavedType))
1021 res.IsOperationSuccess =
false;
1027 if (
res.SavedType !=
res.RequestedType)
1029 res.IsOperationSuccess =
false;
1044 res.IsOperationSuccess =
true;
1057 for (
auto&
eraser : VaultRecordErasers)
1060 RecordsSet.erase(
tmpRec);
1064 if (VaultDerivedClass == VaultDerivedClasses::VaultBase)
1066 tmpRec->RemoveFromDependentSets();
1077 res.IsOperationSuccess =
false;
1093 if (
findResIt != VaultRecordSorters.end())
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:33
bool EraseRecord(const VaultRecordRef &recordRefToErase) noexcept
Method for deleting a record from a Vault.
Definition Vault.cpp:593
VaultOperationResult RequestGreater(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &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:817
VaultOperationResult GetKeyValue(const std::string &key, T &defaultKeyValue) const noexcept
The method for getting a default key value.
Definition Vault.hpp:641
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 RequestEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &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:806
@ VaultBase
Vault class itself.
VaultOperationResult RequestLess(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &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:839
void SortBy(const std::string &key, const F &&func, const bool &isReverse=false, const std::size_t &amountOfRecords=-1) const noexcept
Method for handle sorted records.
Definition Vault.hpp:1085
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:691
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 &)> &requestPredicat) const noexcept
The method for getting the result of the request.
Definition Vault.hpp:304
VaultOperationResult RequestGreaterOrEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &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:828
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:746
VaultDerivedClasses VaultDerivedClass
A variable for storing the object type in the Vault inheritance tree.
Definition Vault.h:106
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 &)> &requestPredicat=DefaultRequestPredicat) const noexcept
The method for getting the result of the request.
Definition Vault.hpp:861
VaultOperationResult Request(const VaultRequest< Type > &&request, VaultRecordSet &vaultRecordSet) const
A method for complex requests.
Definition Vault.hpp:875
VaultOperationResult RequestLessOrEqual(const std::string &key, const T &keyValue, VaultRecordSet &vaultRecordSet, const std::size_t &amountOfRecords=-1, const std::function< bool(const VaultRecordRef &)> &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:850
std::unordered_set< VaultRecordSet * > RecordSetsSet
Unordered set with all VaultRecordSet pointers.
Definition Vault.h:112
VaultOperationResult AddKey(const std::string &key, const T &defaultKeyValue, const bool &isUniqueKey, const bool &isUniqueKeyWithoutLambda, std::function< T(std::size_t, const VaultRecordRef &)> uniqueKeyFunction) noexcept
Template method to add new key with default value to Vault.
Definition Vault.hpp:355
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:1004
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 &)> &requestPredicat) const noexcept
The method for getting the result of the request in the std::set.
Definition Vault.hpp:118
VaultOperationResult UpdateKey(const std::string &key, const T &defaultKeyValue) noexcept
Template method to update default key value.
Definition Vault.hpp:594
VaultOperationResult AddUniqueKey(const std::string &key) noexcept
Template method to add new unique key to Vault.
Definition Vault.hpp:578
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,...
@ TryToUpdateUniqueKey
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:40