Botan 3.6.1
Crypto and TLS for C&
sqlite3.h
Go to the documentation of this file.
1/*
2* SQLite3 wrapper
3* (C) 2012,2014 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_UTILS_SQLITE3_H_
9#define BOTAN_UTILS_SQLITE3_H_
10
11#include <botan/database.h>
12
13#include <optional>
14
15struct sqlite3;
16struct sqlite3_stmt;
17
18namespace Botan {
19
21 public:
22 /**
23 * Create a new SQLite database handle from a file.
24 *
25 * @param file path to the database file be opened and/or created
26 * @param sqlite_open_flags flags that will be passed to sqlite3_open_v2()
27 * (default: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX)
28 */
29 Sqlite3_Database(std::string_view file, std::optional<int> sqlite_open_flags = std::nullopt);
30
31 ~Sqlite3_Database() override;
32
33 size_t row_count(std::string_view table_name) override;
34
35 void create_table(std::string_view table_schema) override;
36
37 size_t rows_changed_by_last_statement() override;
38
39 std::shared_ptr<Statement> new_statement(std::string_view sql) const override;
40
41 bool is_threadsafe() const override;
42
43 private:
44 class Sqlite3_Statement final : public Statement {
45 public:
46 void bind(int column, std::string_view val) override;
47 void bind(int column, size_t val) override;
48 void bind(int column, std::chrono::system_clock::time_point time) override;
49 void bind(int column, const std::vector<uint8_t>& val) override;
50 void bind(int column, const uint8_t* data, size_t len) override;
51
52 std::pair<const uint8_t*, size_t> get_blob(int column) override;
53 std::string get_str(int column) override;
54 size_t get_size_t(int column) override;
55
56 size_t spin() override;
57 bool step() override;
58
59 Sqlite3_Statement(sqlite3* db, std::string_view base_sql);
60 ~Sqlite3_Statement() override;
61
62 private:
63 sqlite3_stmt* m_stmt;
64 };
65
66 sqlite3* m_db;
67};
68
69} // namespace Botan
70
71#endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31