• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5111374265

29 May 2023 11:19AM UTC coverage: 92.227% (+0.5%) from 91.723%
5111374265

push

github

randombit
Next release will be 3.1.0. Update release notes

75588 of 81959 relevant lines covered (92.23%)

11886470.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/src/lib/utils/database.h
1
/*
2
* SQL database interface
3
* (C) 2014 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#ifndef BOTAN_SQL_DATABASE_H_
9
#define BOTAN_SQL_DATABASE_H_
10

11
#include <botan/exceptn.h>
12
#include <botan/types.h>
13
#include <chrono>
14
#include <string>
15
#include <vector>
16

17
namespace Botan {
18

19
class BOTAN_PUBLIC_API(2, 0) SQL_Database {
34✔
20
   public:
21
      class BOTAN_PUBLIC_API(2, 0) SQL_DB_Error final : public Exception {
22
         public:
23
            explicit SQL_DB_Error(std::string_view what) : Exception("SQL database", what), m_rc(0) {}
×
24

25
            SQL_DB_Error(std::string_view what, int rc) : Exception("SQL database", what), m_rc(rc) {}
22✔
26

27
            ErrorType error_type() const noexcept override { return ErrorType::DatabaseError; }
×
28

29
            int error_code() const noexcept override { return m_rc; }
×
30

31
         private:
32
            int m_rc;
33
      };
34

35
      class BOTAN_PUBLIC_API(2, 0) Statement {
820✔
36
         public:
37
            /* Bind statement parameters */
38
            virtual void bind(int column, std::string_view str) = 0;
39

40
            virtual void bind(int column, size_t i) = 0;
41

42
            virtual void bind(int column, std::chrono::system_clock::time_point time) = 0;
43

44
            virtual void bind(int column, const std::vector<uint8_t>& blob) = 0;
45

46
            virtual void bind(int column, const uint8_t* data, size_t len) = 0;
47

48
            /* Get output */
49
            virtual std::pair<const uint8_t*, size_t> get_blob(int column) = 0;
50

51
            virtual std::string get_str(int column) = 0;
52

53
            virtual size_t get_size_t(int column) = 0;
54

55
            /* Run to completion */
56
            virtual size_t spin() = 0;
57

58
            /* Maybe update */
59
            virtual bool step() = 0;
60

61
            virtual ~Statement() = default;
798✔
62
      };
63

64
      /*
65
      * Create a new statement for execution.
66
      * Use ?1, ?2, ?3, etc for parameters to set later with bind
67
      */
68
      virtual std::shared_ptr<Statement> new_statement(std::string_view base_sql) const = 0;
69

70
      virtual size_t row_count(std::string_view table_name) = 0;
71

72
      virtual void create_table(std::string_view table_schema) = 0;
73

74
      virtual size_t rows_changed_by_last_statement() = 0;
75

76
      virtual size_t exec(std::string_view sql) { return new_statement(sql)->spin(); }
114✔
77

78
      virtual bool is_threadsafe() const { return false; }
×
79

80
      virtual ~SQL_Database() = default;
34✔
81
};
82

83
}  // namespace Botan
84

85
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc