5#include "../SqlColumnTypeDefinitions.hpp"
6#include "BasicStringBinder.hpp"
25 using std::vector<uint8_t>::vector;
33 mutable SQLLEN _indicator = 0;
39 static constexpr auto ColumnType = SqlColumnTypeDefinitions::Binary { 255 };
41 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN InputParameter(SQLHSTMT stmt,
43 SqlBinary
const& value,
44 SqlDataBinderCallback& )
noexcept
46 value._indicator =
static_cast<SQLLEN
>(value.size());
47 return SQLBindParameter(stmt,
54 (SQLPOINTER) value.data(),
59 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN OutputColumn(
60 SQLHSTMT stmt, SQLUSMALLINT column, SqlBinary* result, SQLLEN* indicator, SqlDataBinderCallback& cb)
noexcept
65 cb.PlanPostProcessOutputColumn([stmt, column, result, indicator]() {
66 if (*indicator == SQL_NULL_DATA)
69 else if (*indicator == SQL_NO_TOTAL)
71 result->resize(result->size() - 1);
72 else if (std::cmp_less_equal(*indicator,
static_cast<SQLLEN
>(result->size())))
73 result->resize(
static_cast<size_t>(*indicator));
79 auto const totalCharsRequired = *indicator;
80 result->resize(
static_cast<size_t>(totalCharsRequired) + 1);
81 auto const sqlResult =
82 SQLGetData(stmt, column, SQL_C_BINARY, (SQLPOINTER) result->data(), totalCharsRequired + 1, indicator);
84 assert(SQL_SUCCEEDED(sqlResult));
85 assert(*indicator == totalCharsRequired);
86 result->resize(
static_cast<size_t>(totalCharsRequired));
90 return SQLBindCol(stmt, column, SQL_C_BINARY, (SQLPOINTER) result->data(), 255, indicator);
93 static LIGHTWEIGHT_FORCE_INLINE SQLRETURN GetColumn(SQLHSTMT stmt,
97 SqlDataBinderCallback
const& )
noexcept
102 return detail::GetRawColumnArrayData<SQL_C_BINARY>(stmt, column, result, indicator);
105 static LIGHTWEIGHT_FORCE_INLINE std::string Inspect(SqlBinary
const& value)
107 return std::format(
"SqlBinary(size={})", value.size());
Represents a binary data type.
constexpr auto operator<=>(SqlBinary const &) const noexcept=default
Three-way comparison operator.