database.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef LOTRO_DAT_DATABASE_H
  2. #define LOTRO_DAT_DATABASE_H
  3. #include <string>
  4. struct sqlite3;
  5. struct sqlite3_stmt;
  6. extern "C++" {
  7. namespace LOTRO_DAT {
  8. class BinaryData;
  9. class SubfileData;
  10. class Database {
  11. public:
  12. Database();
  13. ~Database();
  14. bool InitDatabase(const std::string &filename);
  15. bool CloseDatabase();
  16. bool PushFile(const SubfileData &data);
  17. SubfileData GetNextFile();
  18. bool RemoveDatabase();
  19. bool ClearDatabase();
  20. size_t CountRows();
  21. private:
  22. void ExecSql(const std::string &sql);
  23. sqlite3* db_;
  24. sqlite3_stmt* insert_request_;
  25. sqlite3_stmt* fetch_one_request_;
  26. sqlite3_stmt* get_rows_number_request_;
  27. const std::string CreateTableCommand_ = "CREATE TABLE IF NOT EXISTS `patch_data` ( "
  28. "`binary_data` BLOB, "
  29. "`text_data` TEXT, "
  30. "`options` TEXT NOT NULL);";
  31. const std::string InsertFileCommand_ = "INSERT INTO `patch_data` "
  32. "(`binary_data`, `text_data`, `options`) "
  33. "VALUES (?, ?, ?); ";
  34. const std::string FetchOneCommand = "SELECT * FROM `patch_data`";
  35. const std::string ClearTableCommand_ = "DELETE * FROM `patch_data`";
  36. const std::string GetRowsNumberCommand_ = "SELECT Count(*) as count FROM `patch_data`";
  37. };
  38. } // namespace LOTRO_DAT
  39. } // extern "C++"
  40. #endif