MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
postgresql_result.hpp
1#ifndef MSTL_DATABASE_POSTGRESQL_RESULT_HPP__
2#define MSTL_DATABASE_POSTGRESQL_RESULT_HPP__
3#ifdef MSTL_SUPPORT_POSTGRESQL__
4#include "MSTL/core/config/undef_cmacro.hpp"
5#include "MSTL/database/db_interface.hpp"
6#include <libpq-fe.h>
8
9class MSTL_API postgresql_tb_result final : public idb_tb_result {
10private:
11 mutable vector<string_view> column_names_;
12 ::PGresult* result_ = nullptr;
13 size_type current_row_ = 0;
14 size_type row_count_ = 0;
15 size_type column_count_ = 0;
16 bool owns_result_;
17
18protected:
19 void init_column_names() const;
20 bool is_null(size_type index) const;
21
22public:
23 explicit postgresql_tb_result(::PGresult* result, bool owns = true) noexcept;
24 ~postgresql_tb_result() override;
25
26 postgresql_tb_result(const postgresql_tb_result&) = delete;
27 postgresql_tb_result& operator =(const postgresql_tb_result&) = delete;
28
29 MSTL_NODISCARD bool empty() const noexcept override { return row_count_ == 0; }
30 MSTL_NODISCARD bool next() noexcept override;
31
32 MSTL_NODISCARD size_type row_count() const noexcept override { return row_count_; }
33 MSTL_NODISCARD size_type column_count() const noexcept override { return column_count_; }
34 MSTL_NODISCARD const vector<string_view>& column_names() const override;
35
36 MSTL_NODISCARD string_view get(size_type index) const override;
37 MSTL_NODISCARD bool get_bool(size_type index) const override;
38 MSTL_NODISCARD int8_t get_int8(size_type index) const override;
39 MSTL_NODISCARD int16_t get_int16(size_type index) const override;
40 MSTL_NODISCARD int32_t get_int32(size_type index) const override;
41 MSTL_NODISCARD int64_t get_int64(size_type index) const override;
42 MSTL_NODISCARD float32_t get_float32(size_type index) const override;
43 MSTL_NODISCARD float64_t get_float64(size_type index) const override;
44 MSTL_NODISCARD decimal_t get_decimal(size_type index) const override;
45 MSTL_NODISCARD vector<char> get_blob(size_type index) const override;
46 MSTL_NODISCARD string get_set(size_type index) const override { return get_string(index); }
47 MSTL_NODISCARD uint64_t get_bit(size_type index) const override;
48 MSTL_NODISCARD _MSTL date get_date(size_type index) const override;
49 MSTL_NODISCARD _MSTL time get_time(size_type index) const override;
50 MSTL_NODISCARD _MSTL datetime get_datetime(size_type index) const override;
51 MSTL_NODISCARD _MSTL timestamp get_timestamp(size_type index) const override;
52 MSTL_NODISCARD string get_string(size_type index) const override { return string{get(index)}; }
53 MSTL_NODISCARD string_view get_enum(size_type index) const override { return get(index); }
54};
55
57#endif
58#endif // MSTL_DATABASE_POSTGRESQL_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位单精度浮点数类型
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
全局命名空间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()))
检查容器是否为空