-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include <string> | ||
#include <fstream> | ||
#include <vector> | ||
#include "Settings.h" | ||
#include "Hash.h" | ||
|
||
namespace Data { | ||
class File { | ||
public: | ||
File(const std::string& path_to_file = DEFAULTPATHTOFILE, size_t size = 0); | ||
size_t size(); | ||
bool isEmpty(); | ||
bool isDifferent(IHash* hash = nullptr); // [FEATURE] Optimize this function | ||
// [FEATURE] Thread isDifferentAsync | ||
void changePathToFile(const std::string& path_to_file); | ||
void createFile(); | ||
void removeFile(); | ||
void push(const std::string& data); | ||
std::string pop(); | ||
std::string pop(const size_t& index); | ||
void remove(const size_t& index); | ||
void save(IHash* hash = nullptr); // [FEATURE] simplify this function, optimize and hash whole file | ||
// [FEATURE] Thread saveAsync | ||
void read(IHash* hash = nullptr); // [FEATURE] simplify this function, optimize and un hash whole file | ||
// [FEATURE] Thread readAsync | ||
std::string& operator[](const size_t& index); // [FEATURE] Add for -> ptr variant | ||
std::vector<std::string>::iterator begin(); | ||
std::vector<std::string>::iterator end(); | ||
|
||
private: | ||
std::vector<std::string> content; | ||
std::string path_to_file; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <string> | ||
#include <vector> | ||
#include "File.h" | ||
|
||
namespace Data { | ||
class Folder { | ||
public: | ||
Folder(const std::filesystem::path& path_to_folder = DEFAULTPATHTOFOLDER); | ||
size_t count(); | ||
bool exist(); | ||
bool isEmpty(); | ||
std::vector<std::string> filesList(); | ||
bool filesListIsDifferent(); // [FEATURE] Optimize this function | ||
// [FEATURE] filesListIsDifferentAsync | ||
void createFolder(); | ||
void removeFolder(); | ||
void createFile(const std::string& file_name); | ||
void removeFile(const std::string& file_name); | ||
void fetchFilesList(); // [FEATURE] Optimize this function | ||
// [FEATURE] fetchFilesListAsync | ||
void updateList(); | ||
bool fileExist(const std::string& file_name); | ||
std::shared_ptr<Data::File> openFile(const std::string& file_name); | ||
void clean(); | ||
std::vector<std::string>::iterator begin(); | ||
std::vector<std::string>::iterator end(); | ||
|
||
private: | ||
std::vector<std::string> files; | ||
std::filesystem::path path_to_folder; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
namespace Data { | ||
class IHash { | ||
public: | ||
virtual std::string hash_function(std::string data) = 0; | ||
virtual std::string un_hash_function(std::string data) = 0; | ||
}; | ||
|
||
// [WARNING] No polish chars | ||
class BaseHash : public IHash { | ||
public: | ||
BaseHash(const char* hash_key); | ||
std::string hash_function(std::string data); | ||
std::string un_hash_function(std::string data); | ||
|
||
private: | ||
const char* hash_key = ""; | ||
}; | ||
|
||
// [FEATURE] Add more hash functions | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include <string> | ||
#include <filesystem> | ||
|
||
const static inline std::string DATASEPERATOR = "sep;"; | ||
const static inline std::string DEFAULTPATHTOFILE = "data.txt"; | ||
const static inline std::filesystem::path DEFAULTPATHTOFOLDER = ""; | ||
|
||
#define DATAHASHBYPARTS false; |
Binary file not shown.
Binary file not shown.