1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef LOTRO_DAT_DATABASE_H
- #define LOTRO_DAT_DATABASE_H
- #include <SQLite/sqlite3.h>
- #include <string>
- #include <yaml-cpp/yaml.h>
- extern "C++" {
- namespace LOTRO_DAT {
- class BinaryData;
- class SubfileData;
- class Database {
- public:
- Database();
- ~Database();
- bool InitDatabase(const std::string &filename);
- bool CloseDatabase();
- bool PushFile(const SubfileData &data);
- SubfileData GetNextFile();
- bool RemoveDatabase();
- bool ClearDatabase();
- size_t CountRows();
- private:
- void ExecSql(const std::string &sql);
- sqlite3* db_;
- sqlite3_stmt* insert_request_;
- sqlite3_stmt* fetch_one_request_;
- sqlite3_stmt* get_rows_number_request_;
- const std::string CreateTableCommand_ = "CREATE TABLE IF NOT EXISTS `patch_data` ( "
- "`binary_data` BLOB, "
- "`text_data` TEXT, "
- "`options` TEXT NOT NULL);";
- const std::string InsertFileCommand_ = "INSERT INTO `patch_data` "
- "(`binary_data`, `text_data`, `options`) "
- "VALUES (?, ?, ?); ";
- const std::string FetchOneCommand = "SELECT * FROM `patch_data`";
- const std::string ClearTableCommand_ = "DELETE * FROM `patch_data`";
- const std::string GetRowsNumberCommand_ = "SELECT Count(*) as count FROM `patch_data`";
- };
- } // namespace LOTRO_DAT
- } // extern "C++"
- #endif
|