1#ifndef MSTL_DATABASE_MYSQL_RESULT_HPP__
2#define MSTL_DATABASE_MYSQL_RESULT_HPP__
3#ifdef MSTL_SUPPORT_MYSQL__
4#include "../../core/config/undef_cmacro.hpp"
5#include "MSTL/database/db_interface.hpp"
12struct MSTL_API mysql_result final : idb_tb_result {
14 ::MYSQL_RES* result_ =
nullptr;
16 size_type columns_ = 0;
17 ::MYSQL_ROW cursor_ =
nullptr;
21 unique_ptr<vector<::enum_field_types>> column_types_ =
25 mysql_result() noexcept = default;
26 explicit mysql_result(::MYSQL_RES* result) noexcept;
28 ~mysql_result()
override {
if (result_) ::mysql_free_result(result_); }
30 MSTL_NODISCARD
bool empty() const noexcept
override {
return result_ ==
nullptr; }
31 MSTL_NODISCARD size_type row_count() const noexcept
override {
return rows_; }
32 MSTL_NODISCARD size_type column_count() const noexcept
override {
return columns_; }
34 MSTL_NODISCARD
const vector<string_view>& column_names() const noexcept
override {
return *column_name_; }
35 MSTL_NODISCARD
const vector<::enum_field_types>& column_types() const noexcept {
return *column_types_; }
37 MSTL_NODISCARD
bool next() noexcept override;
39 MSTL_NODISCARD string_view
get(size_type n) const noexcept override;
41 MSTL_NODISCARD
bool get_bool(size_type n) const override;
42 MSTL_NODISCARD
int8_t get_int8(size_type n) const override;
43 MSTL_NODISCARD
int16_t get_int16(size_type n) const override;
44 MSTL_NODISCARD
int32_t get_int32(size_type n) const override;
45 MSTL_NODISCARD
int64_t get_int64(size_type n) const override;
46 MSTL_NODISCARD
float32_t get_float32(size_type n) const override;
47 MSTL_NODISCARD
float64_t get_float64(size_type n) const override;
48 MSTL_NODISCARD
decimal_t get_decimal(size_type n) const override;
49 MSTL_NODISCARD vector<
char> get_blob(size_type n) const override;
50 MSTL_NODISCARD
string get_set(size_type n) const override;
51 MSTL_NODISCARD
uint64_t get_bit(size_type n) const override;
52 MSTL_NODISCARD
_MSTL date get_date(size_type n) const override;
53 MSTL_NODISCARD
_MSTL time get_time(size_type n) const override;
54 MSTL_NODISCARD
_MSTL datetime get_datetime(size_type n) const override;
55 MSTL_NODISCARD
_MSTL timestamp get_timestamp(size_type n) const override;
56 MSTL_NODISCARD
string get_string(size_type n) const noexcept
override {
return string{
get(n)}; }
57 MSTL_NODISCARD string_view get_enum(size_type n)
const noexcept override {
return get(n); }
MSTL_ALWAYS_INLINE enable_if_t< is_void_v< T >, future_result_t< T > > get(future< T > &f)
通用future结果获取函数
float float32_t
32位单精度浮点数类型
long double decimal_t
扩展精度浮点数类型
long long int64_t
64位有符号整数类型
double float64_t
64位双精度浮点数类型
unsigned long long uint64_t
64位无符号整数类型
signed char int8_t
8位有符号整数类型
constexpr Iterator next(Iterator iter, iter_difference_t< Iterator > n=1)
获取迭代器的后一个位置
#define _MSTL
全局命名空间MSTL前缀
#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