userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
parameter_store.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/postgres/parameter_store.hpp
4
/// @brief @copybrief storages::postgres::ParameterStore
5
6
#
include
<
userver
/
storages
/
postgres
/
detail
/
query_parameters
.
hpp
>
7
#
include
<
userver
/
storages
/
postgres
/
io
/
type_traits
.
hpp
>
8
#
include
<
userver
/
storages
/
postgres
/
io
/
user_types
.
hpp
>
9
#
include
<
userver
/
utils
/
strong_typedef
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
storages::
postgres
{
14
15
/// @ingroup userver_containers
16
///
17
/// @brief Class for dynamic PostgreSQL parameter list construction.
18
///
19
/// Typical use case for this container is to keep parameters around while the
20
/// query is being constructed on the fly:
21
/// @snippet storages/postgres/tests/interval_pgtest.cpp Parameters store sample
22
///
23
/// Note that storages::postgres::Cluster::Execute with explicitly provided
24
/// arguments works slightly faster:
25
/// @snippet storages/postgres/tests/landing_test.cpp Exec sample
26
class
ParameterStore
{
27
public
:
28
ParameterStore() =
default
;
29
ParameterStore(
const
ParameterStore
&) =
delete
;
30
ParameterStore(
ParameterStore
&&) =
default
;
31
ParameterStore
& operator=(
const
ParameterStore
&) =
delete
;
32
ParameterStore
& operator=(
ParameterStore
&&) =
default
;
33
34
/// @brief Adds a parameter to the end of the parameter list.
35
/// @note Currently only built-in/system types are supported.
36
template
<
typename
T>
37
ParameterStore
&
PushBack
(
const
T& param) {
38
static_assert
(
39
io::IsTypeMappedToSystem<T>() || io::IsTypeMappedToSystemArray<T>(),
40
"Currently only built-in types can be used in ParameterStore"
41
);
42
data_.Write(kNoUserTypes, param);
43
return
*
this
;
44
}
37
ParameterStore
&
PushBack
(
const
T& param) {
…
}
45
46
/// Returns whether the parameter list is empty.
47
bool
IsEmpty
()
const
{
return
data_.Size() == 0; }
48
49
/// Returns current size of the list.
50
size_t
Size
()
const
{
return
data_.Size(); }
51
52
/// @cond
53
const
detail::DynamicQueryParameters& GetInternalData()
const
{
return
data_; }
54
/// @endcond
55
56
private
:
57
static
UserTypes
kNoUserTypes;
58
59
detail::DynamicQueryParameters data_;
60
};
26
class
ParameterStore
{
…
};
61
62
}
// namespace storages::postgres
63
64
USERVER_NAMESPACE_END
userver
storages
postgres
parameter_store.hpp
Generated on Wed Apr 30 2025 15:48:43 for userver by
Doxygen
1.13.2