11#pragma once
22
3- #include < cassert>
43#include < string>
54#include < functional>
65#include < stdexcept>
@@ -299,11 +298,10 @@ namespace sqlite {
299298 };
300299
301300 struct sqlite_config {
302- std::string key{};
303301 };
304302
305303 class database {
306- private :
304+ protected :
307305 std::shared_ptr<sqlite3> _db;
308306
309307 public:
@@ -323,16 +321,12 @@ namespace sqlite {
323321 database (std::shared_ptr<sqlite3> db):
324322 _db (db) {}
325323
326- database (const std::string &db_name, const sqlite_config &config):
327- database (std::u16string(db_name.begin(), db_name.end()), config) {}
324+ database (const std::string &db_name, const sqlite_config &config): database(db_name) {
325+ (void )config; // Suppress unused warning
326+ }
328327
329328 database (const std::u16string &db_name, const sqlite_config &config): database(db_name) {
330- #ifdef ENABLE_SQLCIPHER
331- if (!config.key .empty ()) set_key (config.key );
332- #else
333- assert (config.key .empty () && " Encryption supported is disabled." );
334329 (void )config; // Suppress unused warning
335- #endif
336330 }
337331
338332 database_binder operator <<(const std::string& sql) {
@@ -356,28 +350,6 @@ namespace sqlite {
356350 sqlite3_int64 last_insert_rowid () const {
357351 return sqlite3_last_insert_rowid (_db.get ());
358352 }
359-
360- #ifdef ENABLE_SQLCIPHER
361- void set_key (const std::string &key) {
362- if (auto ret = sqlite3_key (_db.get (), key.data (), key.size ()))
363- exceptions::throw_sqlite_error (ret);
364- }
365-
366- void set_key (const std::string &key, const std::string &db_name) {
367- if (auto ret = sqlite3_key_v2 (_db.get (), db_name.c_str (), key.data (), key.size ()))
368- exceptions::throw_sqlite_error (ret);
369- }
370-
371- void rekey (const std::string &new_key) {
372- if (auto ret = sqlite3_rekey (_db.get (), new_key.data (), new_key.size ()))
373- exceptions::throw_sqlite_error (ret);
374- }
375-
376- void rekey (const std::string &new_key, const std::string &db_name) {
377- if (auto ret = sqlite3_rekey_v2 (_db.get (), db_name.c_str (), new_key.data (), new_key.size ()))
378- exceptions::throw_sqlite_error (ret);
379- }
380- #endif
381353 };
382354
383355 template <std::size_t Count>
0 commit comments