StormByte C++ Library: Database module 0.0.9999
StormByte-Database is a StormByte library module for handling database connections
Loading...
Searching...
No Matches
preparedSTMT.hxx
1#pragma once
2
3#include <StormByte/database/preparedSTMT.hxx>
4#include <StormByte/database/row.hxx>
5
10namespace StormByte::Database {
15 template<class Row> class STORMBYTE_DATABASE_PUBLIC PreparedSTMT {
16 public:
22 constexpr PreparedSTMT(const std::string& name, const std::string& query):m_name(name), m_query(query) {}
23
29 constexpr PreparedSTMT(std::string&& name, std::string&& query):m_name(name), m_query(std::move(query)) {}
30
34 PreparedSTMT(const PreparedSTMT&) = delete;
35
39 constexpr PreparedSTMT(PreparedSTMT&&) = default;
40
45
49 constexpr PreparedSTMT& operator=(PreparedSTMT&&) = default;
50
54 virtual constexpr ~PreparedSTMT() = default;
55
61 virtual PreparedSTMT& Bind(const int& index, const std::nullptr_t& value) noexcept = 0;
62
68 virtual PreparedSTMT& Bind(const int& index, const int& value) noexcept = 0;
69
75 virtual PreparedSTMT& Bind(const int& index, const unsigned int& value) noexcept = 0;
76
82 virtual PreparedSTMT& Bind(const int& index, const int64_t& value) noexcept = 0;
83
89 virtual PreparedSTMT& Bind(const int& index, const uint64_t& value) noexcept = 0;
90
96 virtual PreparedSTMT& Bind(const int& index, const double& value) noexcept = 0;
97
103 virtual PreparedSTMT& Bind(const int& index, bool value) noexcept = 0;
104
110 virtual PreparedSTMT& Bind(const int& index, const std::string& value) noexcept = 0;
111
115 virtual void Reset() noexcept = 0;
116
120 virtual const Row& Step() noexcept = 0;
121
126 constexpr const std::string& GetName() const noexcept {
127 return m_name;
128 }
129
134 constexpr const std::string& GetQuery() const noexcept {
135 return m_query;
136 }
137
138 protected:
139 std::string m_name;
140 std::string m_query;
141 std::unique_ptr<Row> m_row;
142 };
143}
Prepared statement for databases.
Definition preparedSTMT.hxx:15
virtual PreparedSTMT & Bind(const int &index, const double &value) noexcept=0
virtual PreparedSTMT & Bind(const int &index, const uint64_t &value) noexcept=0
constexpr PreparedSTMT(PreparedSTMT &&)=default
virtual PreparedSTMT & Bind(const int &index, bool value) noexcept=0
PreparedSTMT & operator=(const PreparedSTMT &)=delete
std::string m_name
Name of the prepared statement.
Definition preparedSTMT.hxx:139
virtual PreparedSTMT & Bind(const int &index, const unsigned int &value) noexcept=0
constexpr PreparedSTMT(std::string &&name, std::string &&query)
Definition preparedSTMT.hxx:29
PreparedSTMT(const PreparedSTMT &)=delete
constexpr PreparedSTMT & operator=(PreparedSTMT &&)=default
virtual PreparedSTMT & Bind(const int &index, const int &value) noexcept=0
std::unique_ptr< Row > m_row
Last result row of the prepared statement.
Definition preparedSTMT.hxx:141
constexpr const std::string & GetQuery() const noexcept
Definition preparedSTMT.hxx:134
virtual PreparedSTMT & Bind(const int &index, const int64_t &value) noexcept=0
std::string m_query
Query to prepare.
Definition preparedSTMT.hxx:140
virtual PreparedSTMT & Bind(const int &index, const std::string &value) noexcept=0
constexpr PreparedSTMT(const std::string &name, const std::string &query)
Definition preparedSTMT.hxx:22
virtual constexpr ~PreparedSTMT()=default
virtual PreparedSTMT & Bind(const int &index, const std::nullptr_t &value) noexcept=0
virtual void Reset() noexcept=0
Row class for databases.
Definition row.hxx:20