userver: userver/storages/mysql/impl/io/binder_declarations.hpp Source File
Loading...
Searching...
No Matches
binder_declarations.hpp
1#pragma once
2
3#include <userver/storages/mysql/impl/io/common_binders.hpp>
4#include <userver/storages/mysql/impl/io/decimal_binder.hpp>
5
6USERVER_NAMESPACE_BEGIN
7
8namespace storages::mysql::impl::io {
9
10template <typename T>
11void BindInput(mysql::impl::InputBindingsFwd& binds, std::size_t pos,
12 const T& field) {
13 using SteadyClock = std::chrono::steady_clock;
14 static_assert(!std::is_same_v<SteadyClock::time_point, T> &&
15 !std::is_same_v<std::optional<SteadyClock::time_point>, T>,
16 "Don't store steady_clock times in the database, use "
17 "system_clock instead");
18
19 storages::mysql::impl::io::FreestandingBind(binds, pos,
20 ExplicitCRef<T>{field});
21}
22
23template <typename T>
24void BindOutput(mysql::impl::OutputBindingsFwd& binds, std::size_t pos,
25 T& field) {
26 static_assert(
27 !std::is_same_v<std::string_view, T> &&
28 !std::is_same_v<std::optional<std::string_view>, T>,
29 "Don't use std::string_view in output params, since it's not-owning");
30
31 storages::mysql::impl::io::FreestandingBind(binds, pos,
32 ExplicitRef<T>{field});
33}
34
35} // namespace storages::mysql::impl::io
36
37USERVER_NAMESPACE_END