userver
C++ Async Framework
Loading...
Searching...
No Matches
parameter_store.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/clickhouse/parameter_store.hpp
4
/// @brief @copybrief storages::clickhouse::ParameterStore
5
6
#
include
<
string_view
>
7
8
#
include
<
fmt
/
args
.
h
>
9
#
include
<
fmt
/
format
.
h
>
10
11
#
include
<
userver
/
storages
/
clickhouse
/
io
/
impl
/
escape
.
hpp
>
12
#
include
<
userver
/
storages
/
query
.
hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
storages::
clickhouse
{
17
18
/// @ingroup userver_containers
19
///
20
/// @brief Class for dynamic ClickHouse parameter list construction.
21
///
22
/// @snippet storages/tests/parameter_store_chtest.cpp basic usage
23
class
ParameterStore
{
24
public
:
25
ParameterStore() =
default
;
26
ParameterStore(
const
ParameterStore
&) =
delete
;
27
ParameterStore(
ParameterStore
&&) =
default
;
28
ParameterStore
& operator=(
const
ParameterStore
&) =
delete
;
29
ParameterStore
& operator=(
ParameterStore
&&) =
default
;
30
31
/// @brief Adds a parameter to the end of the parameter list.
32
/// @note Currently only built-in/system types are supported.
33
template
<
typename
T>
34
ParameterStore
&
PushBack
(
const
T& param) {
35
parameters_.push_back(
io
::impl::Escape(param));
36
return
*
this
;
37
}
38
39
/// @cond
40
// For internal use only
41
Query MakeQueryWithArgs(
const
Query& query)
const
{
42
// we should throw on params count mismatch
43
// TODO : https://st.yandex-team.ru/TAXICOMMON-5066
44
return
Query{fmt::vformat(std::string_view{query.GetStatementView()}, parameters_), query.GetOptionalName()};
45
}
46
/// @endcond
47
48
private
:
49
fmt::dynamic_format_arg_store<fmt::format_context> parameters_{};
50
};
51
52
}
// namespace storages::clickhouse
53
54
USERVER_NAMESPACE_END
userver
storages
clickhouse
parameter_store.hpp
Generated on Fri Aug 22 2025 11:43:06 for userver by
Doxygen
1.9.8