7#include "VaultClasses.h"
10#include "VaultRecord.h"
11#include "VaultRequest.h"
12#include "VaultRecordRef.h"
13#include "VaultParamInput.h"
14#include "VaultOperationResult.h"
16#include "Functions/CsvParser.h"
17#include "Functions/PrintAsTable.h"
60 mutable DataMap VaultMapStructure;
63 std::unordered_map<std::string, std::type_index> KeysTypes;
66 std::unordered_map<std::string, std::function<
bool(
VaultRecord*)>> VaultRecordAdders;
69 std::unordered_map<std::string, std::function<
void()>> VaultRecordClearers;
86 std::list<std::string> KeysOrder;
89 std::set<std::string> UniqueKeys;
92 std::vector<std::pair<std::size_t, std::string>> InvalidFileRecords;
229 template <VaultRequestType Type>
739 bool SaveToFile(
const std::string&
fileName,
const std::vector<std::string>
keys = {},
const std::string& separator =
",",
const bool& isSaveKey =
true)
const noexcept;
751 bool ReadFile(
const std::string& fileName,
const char& separator =
',',
const bool& isLoadKeys =
true,
const std::vector<std::string> keys = {})
noexcept;
765 bool ReadFile(
const std::string& fileName,
const char& separator,
const bool& isLoadKeys, std::function<
void (
const std::vector<std::string>&, std::vector<std::string>&)> recordHandler)
noexcept;
Iterator class for all library maps.
Definition Map.h:18
Specialization of class DataContainer, used as a type std::unordered_map<std::string,...
Definition DataContainer.h:287
Specialization of class DataContainer, used as a type std::map<std::string, DataSaver>
Definition DataContainer.h:309
A class for synchronizing threads.
Definition ReadWriteMutex.h:70
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
friend VaultOperationResult Intersection(const VaultRecordSet &a, const VaultRecordSet &b, VaultRecordSet &res) noexcept
Making Intersection function friendly.
Definition VaultRecordSet.cpp:515
std::size_t Size() const noexcept
Method for getting the number of records.
Definition Vault.cpp:604
std::unordered_set< VaultRecord * >::iterator RemoveRecord(VaultRecord *recordToErase, bool *wasDeleted) noexcept
Method for removing a record from a Vault.
Definition Vault.cpp:9
VaultOperationResult GetKeyValue(const std::string &key, T &defaultKeyValue) const noexcept
The method for getting a default key value.
Definition Vault.hpp:641
void DropData() noexcept
A method for deleting all data, but keeping all keys.
Definition Vault.cpp:572
bool GetKeyType(const std::string &key, std::type_index &keyType) const noexcept
The method for getting a key type.
Definition Vault.cpp:308
std::vector< std::pair< std::size_t, std::string > > GetErrorsInLastReadedFile() const noexcept
A method for getting errors in the last read file.
Definition Vault.cpp:946
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
std::vector< std::string > GetUniqueKeys() const noexcept
The method for getting the unique keys.
Definition Vault.cpp:334
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
VaultDerivedClasses
Enum for storing the object type during inheritance.
Definition Vault.h:100
@ VaultRecordSetDerived
VaultRecordSet class.
@ 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
bool RemoveKey(const std::string &key) noexcept
The method for deleting the key.
Definition Vault.cpp:346
void PrintVault(const std::size_t &amountOfRecords=-1) const noexcept
A method for displaying the contents of a Vault on the screen.
Definition Vault.cpp:685
std::string ToJson(const bool &isFormat=false, const std::size_t &tabSize=2, const bool &isUseRecordTemplate=true, const std::string &recordTemplate="Record") const noexcept
Method for saving the contents of the Vault in json.
Definition Vault.cpp:638
std::unordered_set< VaultRecord * > RecordsSet
Unordered set with all VaultRecord pointers.
Definition Vault.h:109
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
std::vector< VaultRecordRef > GetSortedRecords(const std::string &key, const bool &isReverse=false, const std::size_t &amountOfRecords=-1) const noexcept
Method for getting sorted records.
Definition Vault.cpp:614
VaultDerivedClasses VaultDerivedClass
A variable for storing the object type in the Vault inheritance tree.
Definition Vault.h:106
std::vector< std::string > GetKeys() const noexcept
The method for getting all the keys.
Definition Vault.cpp:322
friend VaultRecordRef
Making the VaultRecordRef class friendly so that it has access to the internal members of the Vault c...
Definition Vault.h:223
VaultOperationResult CreateRecord(const std::vector< std::pair< std::string, VaultParamInput > > ¶ms) noexcept
Method to create new VaultRecord.
Definition Vault.cpp:402
bool ReadFile(const std::string &fileName, const bool &isPreprocessRecord, std::function< void(const std::vector< std::string > &, std::vector< std::string > &)> recordHandler, const char &separator, const bool &isLoadKeys, const std::vector< std::string > userKeys) noexcept
A method for reading a csv file and loading data from it into memory.
Definition Vault.cpp:38
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
void PrintAsTable(bool isPrintId=false, const std::size_t &amountOfRecords=-1, std::string primaryKey="", const bool &isReverse=false, const std::list< std::string > keys={}) const noexcept
A method for displaying the contents of a Vault as a table on the screen.
Definition Vault.cpp:709
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
void DropVault() noexcept
A method for deleting all data and keys.
Definition Vault.cpp:512
Vault() noexcept
Default constructor.
Definition Vault.cpp:176
bool SaveToFile(const std::string &fileName, const std::vector< std::string > keys={}, const std::string &separator=",", const bool &isSaveKey=true) const noexcept
A method for saving data to a table file. The file format is csv.
Definition Vault.cpp:850
std::unordered_set< VaultRecordSet * > RecordSetsSet
Unordered set with all VaultRecordSet pointers.
Definition Vault.h:112
friend bool operator==(const VaultRecordSet &a, const VaultRecordSet &b)
Making VaultRecordSet operator comparison function friendly.
Definition VaultRecordSet.cpp:487
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
friend VaultRecordSet
Making the VaultRecordSet class friendly so that it has access to the internal members of the Vault c...
Definition Vault.h:226
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
bool IsKeyExist(const std::string &key) const noexcept
The method for getting a default key value.
Definition Vault.cpp:300
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
A class for requests to Vault.
Definition VaultRequest.h:16
Structure for storing the results of MVault operations.
Definition VaultOperationResult.h:40