MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
mysql_prepared_result.hpp
1#ifndef MSTL_DATABASE_MYSQL_PREPARED_RESULT_HPP__
2#define MSTL_DATABASE_MYSQL_PREPARED_RESULT_HPP__
3#ifdef MSTL_SUPPORT_MYSQL__
4#include "../../core/config/undef_cmacro.hpp"
5#include "MSTL/database/db_interface.hpp"
6#ifdef CR_OUT_OF_MEMORY
7#undef CR_OUT_OF_MEMORY
8#endif
9#include <mysql.h>
11
12class MSTL_API mysql_prepared_result final : public idb_prepared_result {
13private:
14 ::MYSQL_STMT* stmt_ = nullptr;
15 ::MYSQL_RES* metadata_ = nullptr;
16 uint32_t column_count_ = 0;
17 uint64_t row_count_ = 0;
18 bool has_current_row_ = false;
19
20 unique_ptr<vector<string_view>> column_names_ = make_unique<vector<string_view>>();
21 unique_ptr<vector<::enum_field_types>> column_types_ = make_unique<vector<::enum_field_types>>();
22
23 unique_ptr<vector<::MYSQL_BIND>> bind_results_ = make_unique<vector<::MYSQL_BIND>>();
24 unique_ptr<vector<vector<char>>> buffers_ = make_unique<vector<vector<char>>>();
25 unique_ptr<vector<unsigned long>> lengths_ = make_unique<vector<unsigned long>>();
26 unique_ptr<vector<bool>> is_null_ = make_unique<vector<bool>>();
27 unique_ptr<vector<bool>> is_error_ = make_unique<vector<bool>>();
28
29 void initialize_bindings() const;
30 static size_t get_buffer_size(::enum_field_types type);
31
32public:
33 explicit mysql_prepared_result(::MYSQL_STMT* stmt);
34 ~mysql_prepared_result() override;
35
36 mysql_prepared_result(const mysql_prepared_result&) = delete;
37 mysql_prepared_result& operator =(const mysql_prepared_result&) = delete;
38
39 bool empty() const override { return row_count_ == 0; }
40 bool next() override;
41
42 size_type row_count() const override { return row_count_; }
43 size_type column_count() const override { return column_count_; }
44
45 const vector<string_view>& column_names() const override { return *column_names_; }
46 const vector<::enum_field_types>& column_types() const { return *column_types_; }
47
48 string_view get(size_type n) const override;
49 bool get_bool(size_type n) const override;
50 int8_t get_int8(size_type n) const override;
51 int16_t get_int16(size_type n) const override;
52 int32_t get_int32(size_type n) const override;
53 int64_t get_int64(size_type n) const override;
54 float32_t get_float32(size_type n) const override;
55 float64_t get_float64(size_type n) const override;
56 decimal_t get_decimal(size_type n) const override;
57 vector<char> get_blob(size_type n) const override;
58 string get_set(size_type n) const override;
59 uint64_t get_bit(size_type n) const override;
60 date get_date(size_type n) const override;
61 time get_time(size_type n) const override;
62 datetime get_datetime(size_type n) const override;
63 timestamp get_timestamp(size_type n) const override;
64 string get_string(size_type n) const override { return string(get(n)); }
65 string_view get_enum(size_type n) const override { return get(n); }
66};
67
69#endif
70#endif // MSTL_DATABASE_MYSQL_PREPARED_RESULT_HPP__
MSTL_ALWAYS_INLINE enable_if_t< is_void_v< T >, future_result_t< T > > get(future< T > &f)
通用future结果获取函数
float float32_t
32位单精度浮点数类型
unsigned int uint32_t
32位无符号整数类型
long double decimal_t
扩展精度浮点数类型
long long int64_t
64位有符号整数类型
double float64_t
64位双精度浮点数类型
unsigned long long uint64_t
64位无符号整数类型
short int16_t
16位有符号整数类型
int int32_t
32位有符号整数类型
signed char int8_t
8位有符号整数类型
constexpr Iterator next(Iterator iter, iter_difference_t< Iterator > n=1)
获取迭代器的后一个位置
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
MSTL_NODISCARD MSTL_ALWAYS_INLINE constexpr bool empty(const Container &cont) noexcept(noexcept(cont.empty()))
检查容器是否为空
MSTL_CONSTEXPR20 unique_ptr< T > make_unique(Args &&... args)
创建unique_ptr