Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
PostgresPreparedStatementImpl.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19
20#pragma once
21
24#include <random>
25#include <libpq-fe.h>
26
27namespace sese::db::impl {
28
31 public:
32 explicit PostgresPreparedStatementImpl(std::string stmt_name, std::string stmt_string, uint32_t count, PGconn *conn) noexcept;
33 ~PostgresPreparedStatementImpl() noexcept override;
34
35
36 ResultSet::Ptr executeQuery() noexcept override;
37 int64_t executeUpdate() noexcept override;
38
39 [[nodiscard]] bool setDouble(uint32_t index, const double &value) noexcept override;
40 [[nodiscard]] bool setFloat(uint32_t index, const float &value) noexcept override;
41 [[nodiscard]] bool setInteger(uint32_t index, const int32_t &value) noexcept override;
42 [[nodiscard]] bool setLong(uint32_t index, const int64_t &value) noexcept override;
43 [[nodiscard]] bool setText(uint32_t index, const char *value) noexcept override;
44 [[nodiscard]] bool setNull(uint32_t index) noexcept override;
45 [[nodiscard]] bool setDateTime(uint32_t index, const sese::DateTime &value) noexcept override;
46
47
48 [[nodiscard]] bool getColumnType(uint32_t index, MetadataType &type) noexcept override;
49 [[nodiscard]] int64_t getColumnSize(uint32_t index) noexcept override;
50
51 [[nodiscard]] int getLastError() const noexcept override;
52 [[nodiscard]] const char *getLastErrorMessage() const noexcept override;
53
54 protected:
55 PGconn *conn;
56 std::string stmtName;
57 std::string stmtString;
58 uint32_t count;
60 const char **paramValues;
61 std::string *strings;
62 int error = 0;
63 PGresult *result;
64 };
65
66}// namespace sese::db::impl