Botan 3.0.0
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 {
22 public:
23 /**
24 * Create a new SQLite database handle from a file.
25 *
26 * @param file path to the database file be opened and/or created
27 * @param sqlite_open_flags flags that will be passed to sqlite3_open_v2()
28 * (default: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX)
29 */
30 Sqlite3_Database(std::string_view file, std::optional<int> sqlite_open_flags = std::nullopt);
31
33
34 size_t row_count(std::string_view table_name) override;
35
36 void create_table(std::string_view table_schema) override;
37
38 size_t rows_changed_by_last_statement() override;
39
40 std::shared_ptr<Statement> new_statement(std::string_view sql) const override;
41
42 bool is_threadsafe() const override;
43
44 private:
45 class Sqlite3_Statement final : public Statement
46 {
47 public:
48 void bind(int column, std::string_view val) override;
49 void bind(int column, size_t val) override;
50 void bind(int column, std::chrono::system_clock::time_point time) override;
51 void bind(int column, const std::vector<uint8_t>& val) override;
52 void bind(int column, const uint8_t* data, size_t len) override;
53
54 std::pair<const uint8_t*, size_t> get_blob(int column) override;
55 std::string get_str(int column) override;
56 size_t get_size_t(int column) override;
57
58 size_t spin() override;
59 bool step() override;
60
61 Sqlite3_Statement(sqlite3* db, std::string_view base_sql);
62 ~Sqlite3_Statement();
63 private:
64 sqlite3_stmt* m_stmt;
65 };
66
67 sqlite3* m_db;
68 };
69
70}
71
72#endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:12