StormByte C++ Library: Database module 0.0.9999
StormByte-Database is a StormByte library module for handling database connections
Loading...
Searching...
No Matches
prepared_stmt.hxx
1#pragma once
2
3#include <StormByte/database/prepared_stmt.hxx>
4#include <vector>
5#include <string>
6#include <memory>
7
8// forward-declare the libpq connection struct without including libpq-fe.h
9struct pg_conn;
10
11namespace StormByte::Database::Postgres {
16 class STORMBYTE_DATABASE_PUBLIC PreparedSTMT final: public StormByte::Database::PreparedSTMT {
17 friend class Postgres;
18 public:
23 PreparedSTMT(const PreparedSTMT& other) = delete;
24
29 PreparedSTMT(PreparedSTMT&& other) noexcept = default;
30
34 ~PreparedSTMT() noexcept override = default;
35
41 PreparedSTMT& operator=(const PreparedSTMT& other) = delete;
42
48 PreparedSTMT& operator=(PreparedSTMT&& other) noexcept = default;
49
50 private:
51 struct pg_conn* m_conn;
52 std::string m_stmt_name;
53
54 // parameter storage
55 std::vector<const char*> m_param_values;
56 std::vector<int> m_param_lengths;
57 std::vector<int> m_param_formats;
58 std::vector<std::string> m_string_storage;
59 std::vector<std::vector<char>> m_blob_storage;
60
66 PreparedSTMT(const std::string& name, const std::string& query);
67
73 PreparedSTMT(std::string&& name, std::string&& query) noexcept;
74
80 void Bind(const int& index, const std::nullptr_t& value) noexcept override;
81
87 void Bind(const int& index, const int& value) noexcept override;
88
94 void Bind(const int& index, const unsigned int& value) noexcept override;
95
101 void Bind(const int& index, const int64_t& value) noexcept override;
102
108 void Bind(const int& index, const uint64_t& value) noexcept override;
109
115 void Bind(const int& index, const double& value) noexcept override;
116
122 void Bind(const int& index, bool value) noexcept override;
123
129 void Bind(const int& index, const std::string& value) noexcept override;
130
136 void Bind(const int& index, const std::vector<std::byte>& value) noexcept override;
137
142 ExpectedRows DoExecute() override;
143
147 void Reset() noexcept override;
148 };
149}
Prepared statement for PostgreSQL databases.
Definition prepared_stmt.hxx:16
PreparedSTMT(const PreparedSTMT &other)=delete
PreparedSTMT(PreparedSTMT &&other) noexcept=default
~PreparedSTMT() noexcept override=default
Prepared statement for databases.
Definition prepared_stmt.hxx:14
Forward declaration of libpq connection struct.