Database.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Created by Иван_Архипов on 17.11.2017.
  3. //
  4. #ifndef LOTRO_DAT_PATCHER_DATABASE_H
  5. #define LOTRO_DAT_PATCHER_DATABASE_H
  6. #include "Common/SQLite/sqlite3.h"
  7. #include <string>
  8. #include "yaml-cpp/yaml.h"
  9. extern "C++"
  10. {
  11. namespace LOTRO_DAT
  12. {
  13. class BinaryData;
  14. class SubfileData;
  15. class Database {
  16. public:
  17. Database();
  18. explicit Database(const std::string &filename);
  19. ~Database();
  20. void InitDatabase(const std::string &filename);
  21. void PushFile(const SubfileData &data);
  22. SubfileData GetNextFile();
  23. void RemoveDatabase();
  24. void ClearDatabase();
  25. private:
  26. void ExecSql(const std::string &sql);
  27. sqlite3* db_;
  28. sqlite3_stmt* insert_request_;
  29. sqlite3_stmt* fetch_one_request_;
  30. const std::string CreateTableCommand_ = "CREATE TABLE IF NOT EXISTS `patch_data` ( "
  31. "`binary_data` BLOB, "
  32. "`text_data` TEXT, "
  33. "`options` TEXT NOT NULL);";
  34. const std::string InsertFileCommand_ = "INSERT INTO `patch_data` "
  35. "(`binary_data`, `text_data`, `options`) "
  36. "VALUES (?, ?, ?); ";
  37. const std::string FetchOneCommand = "SELECT * FROM `patch_data`";
  38. const std::string ClearTableCommand_ = "DELETE * FROM `patch_data`";
  39. };
  40. }
  41. }
  42. #endif