3#include "../SqlColumnTypeDefinitions.hpp"
4#include "BasicStringBinder.hpp"
23 using std::vector<uint8_t>::vector;
25 constexpr auto operator<=>(
SqlBinary const&)
const noexcept =
default;
30 mutable SQLLEN _indicator = 0;
36 static constexpr auto ColumnType = SqlColumnTypeDefinitions::Binary { 255 };
38 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN InputParameter(SQLHSTMT stmt,
40 SqlBinary
const& value,
41 SqlDataBinderCallback& )
noexcept
43 value._indicator =
static_cast<SQLLEN
>(value.size());
44 return SQLBindParameter(stmt,
51 (SQLPOINTER) value.data(),
56 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN OutputColumn(
57 SQLHSTMT stmt, SQLUSMALLINT column, SqlBinary* result, SQLLEN* indicator, SqlDataBinderCallback& cb)
noexcept
62 cb.PlanPostProcessOutputColumn([stmt, column, result, indicator]() {
63 if (*indicator == SQL_NULL_DATA)
66 else if (*indicator == SQL_NO_TOTAL)
68 result->resize(result->size() - 1);
69 else if (std::cmp_less_equal(*indicator,
static_cast<SQLLEN
>(result->size())))
70 result->resize(*indicator);
76 auto const totalCharsRequired = *indicator;
77 result->resize(totalCharsRequired + 1);
78 auto const sqlResult =
79 SQLGetData(stmt, column, SQL_C_BINARY, (SQLPOINTER) result->data(), totalCharsRequired + 1, indicator);
81 assert(SQL_SUCCEEDED(sqlResult));
82 assert(*indicator == totalCharsRequired);
83 result->resize(totalCharsRequired);
87 return SQLBindCol(stmt, column, SQL_C_BINARY, (SQLPOINTER) result->data(), 255, indicator);
90 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN GetColumn(SQLHSTMT stmt,
94 SqlDataBinderCallback
const& )
noexcept
99 return detail::GetRawColumnArrayData<SQL_C_BINARY>(stmt, column, result, indicator);
102 static LIGHTWEIGHT_FORCE_INLINE std::string Inspect(SqlBinary
const& value)
104 return std::format(
"SqlBinary(size={})", value.size());
Represents a binary data type.