userver: userver/storages/mysql/command_result_set.hpp Source File
Loading...
Searching...
No Matches
command_result_set.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/mysql/command_result_set.hpp
4
5#include <string>
6
7#include <userver/utils/fast_pimpl.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace storages::mysql {
12
13namespace impl {
14class QueryResult;
15}
16
17/// @brief A wrapper for command result set.
18///
19/// This type can't be constructed in user code and is always retrieved from
20/// storages::mysql::Cluster.
21///
22/// This class doesn't come with much functionality, reach for prepared
23/// statements interface of the storages::mysql::Cluster if you want some.
24class CommandResultSet final {
25 public:
26 explicit CommandResultSet(impl::QueryResult&& mysql_result);
27 ~CommandResultSet();
28
29 CommandResultSet(const CommandResultSet& other) = delete;
30 CommandResultSet(CommandResultSet&& other) noexcept;
31
32 /// @brief Returns amount of rows in the result set.
33 std::size_t RowsCount() const;
34
35 /// @brief Returns amount of columns in the result set.
36 std::size_t FieldsCount() const;
37
38 /// @brief Return true if there are any rows in the result set,
39 /// false otherwise.
40 bool Empty() const;
41
42 /// @brief Returns a value at row `row` at column `column`.
43 const std::string& At(std::size_t row, std::size_t column) const;
44
45 /// @brief Returns a value at row `row` at column `column`.
46 std::string& At(std::size_t row, std::size_t column);
47
48 private:
49 class Impl;
50 utils::FastPimpl<Impl, 24, 8> impl_;
51};
52
53} // namespace storages::mysql
54
55USERVER_NAMESPACE_END