void Cask::CdapOdbc::DataReader::fetchWVarchar(const wchar_t* str, const ColumnBinding& binding) { assert(binding.getTargetType() == SQL_WCHAR || binding.getTargetType() == SQL_DEFAULT); if (str) { std::wstring uniStr = str; size_t maxLength = static_cast<size_t>(binding.getBufferLength()) - 1; size_t size = (uniStr.size() < maxLength) ? uniStr.size() : maxLength; if (binding.getTargetValuePtr()) { wchar_t* outString = static_cast<wchar_t*>(binding.getTargetValuePtr()); auto it = stdext::make_checked_array_iterator<wchar_t*>(outString, size); std::copy(uniStr.begin(), uniStr.begin() + size, it); outString[size] = 0; } if (binding.getStrLenOrInd()) { if (size <= maxLength) { *binding.getStrLenOrInd() = size; } else { *binding.getStrLenOrInd() = SQL_NO_TOTAL; } } } else { if (binding.getTargetValuePtr() && binding.getBufferLength() > 0) { wchar_t* outString = static_cast<wchar_t*>(binding.getTargetValuePtr()); outString[0] = 0; } if (binding.getStrLenOrInd()) { *binding.getStrLenOrInd() = SQL_NULL_DATA; } } }
void Cask::CdapOdbc::DataReader::fetchNull(const ColumnBinding& binding) { if (binding.getStrLenOrInd()) { *binding.getStrLenOrInd() = SQL_NULL_DATA; } }