aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/vendor/sqlite3/sqlite3.h
blob: 8495a1d1bb050bc51ac16fab2f2f1504726b71a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* SQLite3 wrapper
* (C) 2012,2014 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#ifndef BOTAN_UTILS_SQLITE3_H__
#define BOTAN_UTILS_SQLITE3_H__

#include <botan/database.h>

class sqlite3;
class sqlite3_stmt;

namespace Botan {

class BOTAN_DLL Sqlite3_Database  : public SQL_Database
   {
   public:
      Sqlite3_Database(const std::string& file);

      ~Sqlite3_Database();

      size_t row_count(const std::string& table_name) override;

      void create_table(const std::string& table_schema) override;

      std::shared_ptr<Statement> new_statement(const std::string& sql) const override;
   private:
      class Sqlite3_Statement : public Statement
         {
         public:
            void bind(int column, const std::string& val) override;
            void bind(int column, size_t val) override;
            void bind(int column, std::chrono::system_clock::time_point time) override;
            void bind(int column, const std::vector<byte>& val) override;

            std::pair<const byte*, size_t> get_blob(int column) override;
            size_t get_size_t(int column) override;

            void spin() override;
            bool step() override;

            Sqlite3_Statement(sqlite3* db, const std::string& base_sql);
            ~Sqlite3_Statement();
         private:
            sqlite3_stmt* m_stmt;
         };

      sqlite3* m_db;
   };

}

#endif