feat(Core/Database): add support set arguments for PrepareStatment (#10066)

- partical cherrypick 0b3f073ca2
This commit is contained in:
Kargatum
2022-01-21 09:45:46 +07:00
committed by GitHub
parent cc1fc27ae5
commit 2ca5ad6af5
2 changed files with 127 additions and 0 deletions

View File

@@ -29,6 +29,52 @@ m_index(index), statement_data(capacity) { }
PreparedStatementBase::~PreparedStatementBase() { }
//- Bind to buffer
template<typename T>
Acore::Types::is_non_string_view_v<T> PreparedStatementBase::SetValidData(const uint8 index, T const& value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.emplace<T>(value);
}
template<>
void PreparedStatementBase::SetValidData(const uint8 index, std::string const& value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.emplace<std::string>(value);
}
template<>
void PreparedStatementBase::SetValidData(const uint8 index, std::vector<uint8> const& value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.emplace<std::vector<uint8>>(value);
}
// Non template functions
void PreparedStatementBase::SetValidData(const uint8 index)
{
ASSERT(index < statement_data.size());
statement_data[index].data.emplace<std::nullptr_t>(nullptr);
}
void PreparedStatementBase::SetValidData(const uint8 index, std::string_view value)
{
ASSERT(index < statement_data.size());
statement_data[index].data.emplace<std::string>(value);
}
template void PreparedStatementBase::SetValidData(const uint8 index, uint8 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, int8 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, uint16 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, int16 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, uint32 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, int32 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, uint64 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, int64 const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, bool const& value);
template void PreparedStatementBase::SetValidData(const uint8 index, float const& value);
// Old api
void PreparedStatementBase::setBool(const uint8 index, const bool value)
{
ASSERT(index < statement_data.size());