5#include "../SqlColumnTypeDefinitions.hpp"
6#include "BasicStringBinder.hpp"
25 using std::vector<uint8_t>::vector;
27 constexpr auto operator<=>(
SqlBinary const&)
const noexcept =
default;
32 mutable SQLLEN _indicator = 0;
38 static constexpr auto ColumnType = SqlColumnTypeDefinitions::Binary { 255 };
40 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN InputParameter(SQLHSTMT stmt,
42 SqlBinary
const& value,
43 SqlDataBinderCallback& )
noexcept
45 value._indicator =
static_cast<SQLLEN
>(value.size());
46 return SQLBindParameter(stmt,
53 (SQLPOINTER) value.data(),
58 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN OutputColumn(
59 SQLHSTMT stmt, SQLUSMALLINT column, SqlBinary* result, SQLLEN* indicator, SqlDataBinderCallback& cb)
noexcept
64 cb.PlanPostProcessOutputColumn([stmt, column, result, indicator]() {
65 if (*indicator == SQL_NULL_DATA)
68 else if (*indicator == SQL_NO_TOTAL)
70 result->resize(result->size() - 1);
71 else if (std::cmp_less_equal(*indicator,
static_cast<SQLLEN
>(result->size())))
72 result->resize(
static_cast<size_t>(*indicator));
78 auto const totalCharsRequired = *indicator;
79 result->resize(
static_cast<size_t>(totalCharsRequired) + 1);
80 auto const sqlResult =
81 SQLGetData(stmt, column, SQL_C_BINARY, (SQLPOINTER) result->data(), totalCharsRequired + 1, indicator);
83 assert(SQL_SUCCEEDED(sqlResult));
84 assert(*indicator == totalCharsRequired);
85 result->resize(
static_cast<size_t>(totalCharsRequired));
89 return SQLBindCol(stmt, column, SQL_C_BINARY, (SQLPOINTER) result->data(), 255, indicator);
92 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN GetColumn(SQLHSTMT stmt,
96 SqlDataBinderCallback
const& )
noexcept
101 return detail::GetRawColumnArrayData<SQL_C_BINARY>(stmt, column, result, indicator);
104 static LIGHTWEIGHT_FORCE_INLINE std::string Inspect(SqlBinary
const& value)
106 return std::format(
"SqlBinary(size={})", value.size());
Represents a binary data type.