Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
MariaPreparedStatementImpl.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
25namespace sese::db::impl {
26
29 public:
30 explicit MariaPreparedStatementImpl(MYSQL_STMT *stmt, MYSQL_RES *meta, size_t count) noexcept;
31 ~MariaPreparedStatementImpl() noexcept override;
32
33 ResultSet::Ptr executeQuery() noexcept override;
34 int64_t executeUpdate() noexcept override;
35
36 bool setDouble(uint32_t index, const double &value) noexcept override;
37 bool setFloat(uint32_t index, const float &value) noexcept override;
38 bool setInteger(uint32_t index, const int32_t &value) noexcept override;
39 bool setLong(uint32_t index, const int64_t &value) noexcept override;
40 bool setText(uint32_t index, const char *value) noexcept override;
41 bool setNull(uint32_t index) noexcept override;
42 bool setDateTime(uint32_t index, const sese::DateTime &value) noexcept override;
43
44 bool getColumnType(uint32_t index, MetadataType &type) noexcept override;
45 int64_t getColumnSize(uint32_t index) noexcept override;
46
47 [[nodiscard]] int getLastError() const noexcept override;
48 [[nodiscard]] const char *getLastErrorMessage() const noexcept override;
49
50 static bool mallocBindStruct(MYSQL_RES *meta, MYSQL_BIND **bind) noexcept;
51 static void freeBindStruct(MYSQL_BIND *bind, size_t count) noexcept;
52 static void reinterpret(MYSQL_BIND *target, enum_field_types expece_type, const void *buffer, size_t size) noexcept;
53
54 protected:
55 MYSQL_STMT *stmt;
56 size_t count = 0;
57 MYSQL_BIND *param;
58 MYSQL_RES *meta;
59 };
60
61}// namespace sese::db