| 45 | |
| 46 | template <typename O> |
| 47 | inline SQLRETURN GetAttributeUTF8(std::string_view attribute_value, SQLPOINTER output, |
| 48 | O output_size, O* output_len_ptr) { |
| 49 | if (output) { |
| 50 | size_t output_len_before_null = |
| 51 | std::min(static_cast<O>(attribute_value.size()), static_cast<O>(output_size - 1)); |
| 52 | std::memcpy(output, attribute_value.data(), output_len_before_null); |
| 53 | reinterpret_cast<char*>(output)[output_len_before_null] = '\0'; |
| 54 | } |
| 55 | |
| 56 | if (output_len_ptr) { |
| 57 | *output_len_ptr = static_cast<O>(attribute_value.size()); |
| 58 | } |
| 59 | |
| 60 | if (output && output_size < static_cast<O>(attribute_value.size() + 1)) { |
| 61 | return SQL_SUCCESS_WITH_INFO; |
| 62 | } |
| 63 | return SQL_SUCCESS; |
| 64 | } |
| 65 | |
| 66 | template <typename O> |
| 67 | inline SQLRETURN GetAttributeUTF8(std::string_view attribute_value, SQLPOINTER output, |
no test coverage detected