userver: userver/storages/postgres/portal.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
portal.hpp
1#pragma once
2
3#include <memory>
4#include <string>
5
6#include <userver/engine/deadline.hpp>
7
8#include <userver/storages/postgres/detail/connection_ptr.hpp>
9#include <userver/storages/postgres/detail/query_parameters.hpp>
10#include <userver/storages/postgres/options.hpp>
11#include <userver/storages/postgres/postgres_fwd.hpp>
12#include <userver/storages/postgres/query.hpp>
13#include <userver/storages/postgres/result_set.hpp>
14
15#include <userver/utils/fast_pimpl.hpp>
16#include <userver/utils/strong_typedef.hpp>
17
18USERVER_NAMESPACE_BEGIN
19
20namespace storages::postgres {
21
22using PortalName =
23 USERVER_NAMESPACE::utils::StrongTypedef<struct PortalNameTag, std::string>;
24
25class Portal {
26 public:
27 Portal(detail::Connection* conn, const Query& query,
28 const detail::QueryParameters& = {},
29 OptionalCommandControl cmd_ctl = {});
30 Portal(detail::Connection* conn, const PortalName&, const Query& query,
31 const detail::QueryParameters& = {},
32 OptionalCommandControl cmd_ctl = {});
33
34 Portal(Portal&&) noexcept;
35 Portal& operator=(Portal&&) noexcept;
36
37 Portal(const Portal&) = delete;
38 Portal& operator=(const Portal&) = delete;
39
40 ~Portal();
41
42 ResultSet Fetch(std::uint32_t n_rows);
43
44 bool Done() const;
45 std::size_t FetchedSoFar() const;
46
47 explicit operator bool() const { return !Done(); }
48
49 private:
50 static constexpr std::size_t kImplSize = 88;
51 static constexpr std::size_t kImplAlign = 8;
52
53 struct Impl;
54 USERVER_NAMESPACE::utils::FastPimpl<Impl, kImplSize, kImplAlign> pimpl_;
55};
56
57} // namespace storages::postgres
58
59USERVER_NAMESPACE_END