//===----------------------------------------------------------------------===// // DuckDB // // duckdb/main/capi/cast/generic_cast.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/common/types/time.hpp" #include "duckdb/common/types/timestamp.hpp" #include "duckdb/common/types/date.hpp" #include "duckdb/main/capi/capi_internal.hpp" #include "duckdb/main/capi/cast/utils.hpp" #include "duckdb/main/capi/cast/from_decimal.hpp" namespace duckdb { template RESULT_TYPE GetInternalCValue(duckdb_result *result, idx_t col, idx_t row) { if (!CanFetchValue(result, col, row)) { return FetchDefaultValue::Operation(); } switch (result->__deprecated_columns[col].__deprecated_type) { case DUCKDB_TYPE_BOOLEAN: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_TINYINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_SMALLINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_INTEGER: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_BIGINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_UTINYINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_USMALLINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_UINTEGER: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_UBIGINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_FLOAT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_DOUBLE: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_DATE: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_TIME: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_TIMESTAMP: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_HUGEINT: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_DECIMAL: return TryCastDecimalCInternal(result, col, row); case DUCKDB_TYPE_INTERVAL: return TryCastCInternal(result, col, row); case DUCKDB_TYPE_VARCHAR: return TryCastCInternal>(result, col, row); case DUCKDB_TYPE_BLOB: return TryCastCInternal(result, col, row); default: { // LCOV_EXCL_START // invalid type for C to C++ conversion D_ASSERT(0); return FetchDefaultValue::Operation(); } // LCOV_EXCL_STOP } } } // namespace duckdb