1
1
#pragma once
2
2
3
- #include < cassert>
4
3
#include < string>
5
4
#include < functional>
6
5
#include < stdexcept>
@@ -299,11 +298,10 @@ namespace sqlite {
299
298
};
300
299
301
300
struct sqlite_config {
302
- std::string key{};
303
301
};
304
302
305
303
class database {
306
- private :
304
+ protected :
307
305
std::shared_ptr<sqlite3> _db;
308
306
309
307
public:
@@ -323,16 +321,12 @@ namespace sqlite {
323
321
database (std::shared_ptr<sqlite3> db):
324
322
_db (db) {}
325
323
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
+ }
328
327
329
328
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." );
334
329
(void )config; // Suppress unused warning
335
- #endif
336
330
}
337
331
338
332
database_binder operator <<(const std::string& sql) {
@@ -356,28 +350,6 @@ namespace sqlite {
356
350
sqlite3_int64 last_insert_rowid () const {
357
351
return sqlite3_last_insert_rowid (_db.get ());
358
352
}
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
381
353
};
382
354
383
355
template <std::size_t Count>
0 commit comments