GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
DataObjectOperator.h
1 
29 #ifndef GPGFRONTEND_DATAOBJECTOPERATOR_H
30 #define GPGFRONTEND_DATAOBJECTOPERATOR_H
31 
32 #include <json/single_include/nlohmann/json.hpp>
33 
34 #include "core/GpgFrontendCore.h"
35 #include "core/GpgFunctionObject.h"
36 #include "core/function/GlobalSettingStation.h"
37 
38 namespace GpgFrontend {
39 
40 class GPGFRONTEND_CORE_EXPORT DataObjectOperator
41  : public SingletonFunctionObject<DataObjectOperator> {
42  public:
48  explicit DataObjectOperator(
50 
51  std::string SaveDataObj(const std::string &_key, const nlohmann::json &value);
52 
53  std::optional<nlohmann::json> GetDataObject(const std::string &_key);
54 
55  std::optional<nlohmann::json> GetDataObjectByRef(const std::string &_ref);
56 
57  private:
62  void init_app_secure_key();
63 
64  GlobalSettingStation &global_setting_station_ =
66  std::filesystem::path app_secure_path_ =
67  global_setting_station_.GetAppConfigPath() /
68  "secure";
69  std::filesystem::path app_secure_key_path_ =
70  app_secure_path_ / "app.key";
71  std::filesystem::path app_data_objs_path_ =
72  global_setting_station_.GetAppDataPath() / "data_objs";
73 
76  std::random_device rd_;
77  std::mt19937 mt_ = std::mt19937(rd_());
78  QByteArray hash_key_;
79 };
80 
81 } // namespace GpgFrontend
82 
83 #endif // GPGFRONTEND_DATAOBJECTOPERATOR_H
GpgFrontend::SingletonFunctionObject
Definition: GpgFunctionObject.h:49
GpgFrontend::FileOperator::WriteFileStd
static bool WriteFileStd(const std::filesystem::path &file_name, const std::string &data)
write file content using std struct
Definition: FileOperator.cpp:67
GpgFrontend::DataObjectOperator::rd_
std::random_device rd_
Random device.
Definition: DataObjectOperator.h:76
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::SingletonFunctionObject< PassphraseGenerator >::GetInstance
static PassphraseGenerator & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:57
GpgFrontend::DataObjectOperator::app_secure_path_
std::filesystem::path app_secure_path_
Where sensitive information is stored.
Definition: DataObjectOperator.h:66
GpgFrontend::DataObjectOperator::app_secure_key_path_
std::filesystem::path app_secure_key_path_
Where the key of data object is stored.
Definition: DataObjectOperator.h:69
GpgFrontend::DataObjectOperator::DataObjectOperator
DataObjectOperator(int channel=SingletonFunctionObject::GetDefaultChannel())
DataObjectOperator constructor.
Definition: DataObjectOperator.cpp:46
GpgFrontend::DataObjectOperator::hash_key_
QByteArray hash_key_
Hash key.
Definition: DataObjectOperator.h:78
GpgFrontend::GlobalSettingStation
Definition: GlobalSettingStation.h:47
GpgFrontend::DataObjectOperator::app_data_objs_path_
std::filesystem::path app_data_objs_path_
Definition: DataObjectOperator.h:71
GpgFrontend::SingletonFunctionObject::GetDefaultChannel
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:127
GpgFrontend::FileOperator::ReadFileStd
static bool ReadFileStd(const std::filesystem::path &file_name, std::string &data)
read file content using std struct
Definition: FileOperator.cpp:55
GpgFrontend::DataObjectOperator
Definition: DataObjectOperator.h:40
GpgFrontend::DataObjectOperator::init_app_secure_key
void init_app_secure_key()
init the secure key of application data object
Definition: DataObjectOperator.cpp:37