userver: userver/storages/mysql/query.hpp Source File
Loading...
Searching...
No Matches
query.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/mysql/query.hpp
4
5#include <optional>
6#include <string>
7
8#include <userver/utils/strong_typedef.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace storages::mysql {
13
14/// @brief Query class, which driver executes.
15class Query final {
16 public:
17 /// @brief Strong typedef for query name, one can use named queries to get
18 /// better logging experience
19 using Name = utils::StrongTypedef<struct NameTag, std::string>;
20
21 /// @brief Query constructor
22 Query(const char* statement, std::optional<Name> name = std::nullopt);
23
24 /// @brief Query constructor
25 Query(std::string statement, std::optional<Name> name = std::nullopt);
26
27 /// @brief Get query statement
28 const std::string& GetStatement() const;
29
30 /// @brief Get query name
31 const std::optional<Name>& GetName() const;
32
33 private:
34 std::string statement_;
35 std::optional<Name> name_;
36};
37
38} // namespace storages::mysql
39
40USERVER_NAMESPACE_END