MVault 0.0.1
Loading...
Searching...
No Matches
VaultRecordSet.h
1#pragma once
2
3#include "Vault.h"
4
5namespace mvlt
6{
13 class VaultRecordSet : protected Vault
14 {
15 private:
16
17 // Pointer to parent Vault
18 Vault* ParentVault = nullptr;
19
38 template <class T>
39 VaultOperationResult RequestRecords(const VaultRequestType& requestType, const std::string& key, const T& beginKeyValue,
41 const bool& isIncludeEndKeyValue, const std::size_t& amountOfRecords, const std::function<bool(const VaultRecordRef&)>& requestPredicat) const noexcept;
42
53 std::unordered_set<VaultRecord *>::iterator RemoveRecord(VaultRecord* recordToErase, bool* wasDeleted) noexcept;
54
60 void CopySet(const VaultRecordSet& other) noexcept;
61
67 void MoveSet(VaultRecordSet& other) noexcept;
68
69 public:
70
72 friend Vault;
73
76
79
86
95
102
111
114
121
128
136 bool IsKeyExist(const std::string& key) const noexcept;
137
148
158
165
184
200
217 const std::size_t& amountOfRecords = -1, const std::function<bool(const VaultRecordRef&)>& requestPredicat = DefaultRequestPredicat) const;
218
235 const std::size_t& amountOfRecords = -1, const std::function<bool(const VaultRecordRef&)>& requestPredicat = DefaultRequestPredicat) const;
236
253 const std::size_t& amountOfRecords = -1, const std::function<bool(const VaultRecordRef&)>& requestPredicat = DefaultRequestPredicat) const;
254
271 const std::size_t& amountOfRecords = -1, const std::function<bool(const VaultRecordRef&)>& requestPredicat = DefaultRequestPredicat) const;
272
289 const std::size_t& amountOfRecords = -1, const std::function<bool(const VaultRecordRef&)>& requestPredicat = DefaultRequestPredicat) const;
290
312 const std::function<bool(const VaultRecordRef&)>& requestPredicat = DefaultRequestPredicat) const;
313
320 template <VaultRequestType Type>
322
331
333 void Reset() noexcept;
334
341 void Clear() noexcept;
342
352 bool RemoveRecord(const VaultRecordRef& recordRefToErase) noexcept;
353
367 VaultOperationResult RemoveRecord(const std::string& key, const T& keyValue) noexcept;
368
386
394 std::size_t Size() const noexcept;
395
403 std::vector<std::string> GetKeys() const noexcept;
404
417
437 void SortBy(const std::string& key, const F&& func, const bool& isReverse = false, const std::size_t& amountOfRecords = -1) const noexcept;
438
449 std::string ToJson(const bool& isFormat = false, const std::size_t& tabSize = 2, const bool& isUseRecordTemplate = true,
451
457 void PrintSet(const std::size_t& amountOfRecords = -1) const noexcept;
458
468 void PrintAsTable(bool isPrintId = false, const std::size_t& amountOfRecords = -1, std::string primaryKey = "", const bool& isReverse = false,
469 const std::list<std::string> keys = {}) const noexcept;
470
478 VaultOperationResult Join(const VaultRecordSet& a) noexcept;
479
488
497
510 bool SaveToFile(const std::string& fileName, const std::vector<std::string> keys = {}, const std::string& separator = ",", const bool& isSaveKey = true) const noexcept;
511
513 ~VaultRecordSet() noexcept;
514
516 friend VaultOperationResult Union(const VaultRecordSet& a, const VaultRecordSet& b, VaultRecordSet& res) noexcept;
517
519 friend VaultOperationResult Intersection(const VaultRecordSet& a, const VaultRecordSet& b, VaultRecordSet& res) noexcept;
520 };
521
530 bool operator==(const VaultRecordSet& a, const VaultRecordSet& b);
531
541 VaultOperationResult Union(const VaultRecordSet& a, const VaultRecordSet& b, VaultRecordSet& res) noexcept;
542
552 VaultOperationResult Intersection(const VaultRecordSet& a, const VaultRecordSet& b, VaultRecordSet& res) noexcept;
553}
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
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
bool CheckRecord(const VaultRecordRef &ref) const noexcept
A method for checking for an entry in set.
Definition VaultRecordSet.cpp:209
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 VaultRecordSet.hpp:85
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 VaultRecordSet.hpp:280
bool IsKeyExist(const std::string &key) const noexcept
The method for getting a default key value.
Definition VaultRecordSet.cpp:136
friend VaultOperationResult Intersection(const VaultRecordSet &a, const VaultRecordSet &b, VaultRecordSet &res) noexcept
Making Intersection function friendly.
Definition VaultRecordSet.cpp:515
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
A method for getting all records that have a value less than keyValue stored by the key key.
Definition VaultRecordSet.hpp:153
std::size_t Size() const noexcept
Method for getting the number of records.
Definition VaultRecordSet.cpp:254
VaultOperationResult Intersect(const VaultRecordSet &a) noexcept
A method to delete all records from this that are not in a.
Definition VaultRecordSet.cpp:421
std::vector< std::string > GetKeys() const noexcept
The method for getting all the keys.
Definition VaultRecordSet.cpp:267
VaultRecordSet() noexcept
Default constructor.
Definition VaultRecordSet.cpp:75
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
A method for getting all records that have a value less than or equal to keyValue stored by the key k...
Definition VaultRecordSet.hpp:160
friend VaultOperationResult Union(const VaultRecordSet &a, const VaultRecordSet &b, VaultRecordSet &res) noexcept
Making Union function friendly.
Definition VaultRecordSet.cpp:497
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 VaultRecordSet.cpp:313
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
A method for getting all records that have a value greater than or equal to keyValue stored by the ke...
Definition VaultRecordSet.hpp:146
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
A method for getting all records that have a value greater than keyValue stored by the key key.
Definition VaultRecordSet.hpp:139
VaultOperationResult Exclude(const VaultRecordSet &a) noexcept
A method for deleting all records from this that are also in a.
Definition VaultRecordSet.cpp:374
void Reset() noexcept
Resets the object to its initial state.
Definition VaultRecordSet.cpp:216
bool GetKeyType(const std::string &key, std::type_index &keyType) const noexcept
The method for getting a key type.
Definition VaultRecordSet.cpp:146
std::string GetParentVaultUniqueId() const noexcept
Method for getting parent vault unique id.
Definition VaultRecordSet.cpp:124
VaultOperationResult Request(const VaultRequest< Type > &&request, VaultRecordSet &vaultRecordSet) const
A method for complex requests.
Definition VaultRecordSet.hpp:178
void PrintSet(const std::size_t &amountOfRecords=-1) const noexcept
A method for displaying the contents of a Vault on the screen.
Definition VaultRecordSet.cpp:302
friend VaultRecord
Make VaultRecord class friend.
Definition VaultRecordSet.h:75
~VaultRecordSet() noexcept
Destructor.
Definition VaultRecordSet.cpp:481
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
A method for getting all records that have a value equal to keyValue stored by the key key.
Definition VaultRecordSet.hpp:132
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 VaultRecordSet in json.
Definition VaultRecordSet.cpp:290
friend Vault
Make Vault class friend.
Definition VaultRecordSet.h:72
void Clear() noexcept
Clear VaultRecordSet.
Definition VaultRecordSet.cpp:229
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 VaultRecordSet.cpp:277
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 VaultRecordSet.cpp:468
VaultOperationResult RemoveRecords(const std::string &key, const T &keyValue, const std::size_t &amountOfRecords=-1) noexcept
The method for remove records using key and value.
Definition VaultRecordSet.hpp:255
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 VaultRecordSet.hpp:108
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
The method for getting the result of the request.
Definition VaultRecordSet.hpp:167
VaultOperationResult Join(const VaultRecordSet &a) noexcept
A method for adding all records from a to this.
Definition VaultRecordSet.cpp:325
VaultOperationResult AddRecord(const VaultRecordRef &recordRef) noexcept
Method for adding a record to VaultRecordSet.
Definition VaultRecordSet.cpp:159
bool GetIsParentVaultValid() const noexcept
Method for checking the validity of the parent Vault.
Definition VaultRecordSet.cpp:119
VaultOperationResult GetKeyValue(const std::string &key, T &defaultKeyValue) const noexcept
The method for getting a default key value.
Definition VaultRecordSet.hpp:64
A class for requests to Vault.
Definition VaultRequest.h:16
Structure for storing the results of MVault operations.
Definition VaultOperationResult.h:40