6#ifndef ATLASGAMEMANAGER_BINDERS_HPP
7#define ATLASGAMEMANAGER_BINDERS_HPP
15template <
typename T >
16[[nodiscard]]
int bindParameter( sqlite3_stmt*,
const T,
const int )
noexcept =
delete;
18template <
typename T >
19 requires std::is_integral_v< T >
20[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const T val,
const int idx )
noexcept
22 return sqlite3_bind_int64( stmt, idx,
static_cast< sqlite3_int64
>( val ) );
25template <
typename T >
26 requires std::is_same_v< T, QString >
27[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const QString val,
const int idx )
noexcept
29 const QByteArray utf8_text { val.toUtf8() };
30 return sqlite3_bind_text( stmt, idx, utf8_text.data(),
static_cast< int >( utf8_text.size() ), SQLITE_TRANSIENT );
33template <
typename T >
34 requires std::is_same_v< T, std::u8string >
35[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const std::u8string val,
const int idx )
noexcept
37 return sqlite3_bind_text(
38 stmt, idx,
reinterpret_cast< const char*
>( val.c_str() ),
static_cast< int >( val.size() ), SQLITE_TRANSIENT );
41template <
typename T >
42 requires std::is_same_v< T, std::string_view >
43[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const std::string_view val,
const int idx )
noexcept
46 return sqlite3_bind_text( stmt, idx, val.data(),
static_cast< int >( val.size() ), SQLITE_TRANSIENT );
48 QString str { QString::fromLocal8Bit( val.data(),
static_cast< qsizetype
>( val.size() ) ) };
53template <
typename T >
54 requires std::is_same_v< T, std::filesystem::path >
55[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const std::filesystem::path val,
const int idx )
noexcept
60template <
typename T >
61 requires std::is_same_v< T, std::vector< std::byte > >
62[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const std::vector< std::byte > val,
const int idx )
noexcept
64 return sqlite3_bind_blob( stmt, idx, val.data(),
static_cast< int >( val.size() ),
nullptr );
67template <
typename T >
68 requires std::is_same_v< T, std::nullopt_t >
70 bindParameter( sqlite3_stmt* stmt, [[maybe_unused]]
const std::nullopt_t nullopt,
const int idx )
noexcept
72 return sqlite3_bind_null( stmt, idx );
75template <
typename T >
76 requires std::is_floating_point_v< T >
77[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const T val,
const int idx )
noexcept
79 return sqlite3_bind_double( stmt, idx, val );
82template <
typename T >
83 requires std::is_same_v< std::string, T >
84[[nodiscard]]
int bindParameter( sqlite3_stmt* stmt,
const T val,
const int idx )
noexcept
int bindParameter(sqlite3_stmt *, const T, const int) noexcept=delete
Definition binders.hpp:20