1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/common/operator/string_cast.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/common.hpp"
12#include "duckdb/common/types.hpp"
13#include "duckdb/common/exception.hpp"
14#include "duckdb/common/types/string_type.hpp"
15
16namespace duckdb {
17
18//! StringCast
19class Vector;
20
21struct StringCast {
22 template <class SRC>
23 static inline string_t Operation(SRC input, Vector &result) {
24 throw NotImplementedException("Unimplemented type for string cast!");
25 }
26};
27
28template <>
29DUCKDB_API duckdb::string_t StringCast::Operation(bool input, Vector &result);
30template <>
31DUCKDB_API duckdb::string_t StringCast::Operation(int8_t input, Vector &result);
32template <>
33DUCKDB_API duckdb::string_t StringCast::Operation(int16_t input, Vector &result);
34template <>
35DUCKDB_API duckdb::string_t StringCast::Operation(int32_t input, Vector &result);
36template <>
37DUCKDB_API duckdb::string_t StringCast::Operation(int64_t input, Vector &result);
38template <>
39DUCKDB_API duckdb::string_t StringCast::Operation(uint8_t input, Vector &result);
40template <>
41DUCKDB_API duckdb::string_t StringCast::Operation(uint16_t input, Vector &result);
42template <>
43DUCKDB_API duckdb::string_t StringCast::Operation(uint32_t input, Vector &result);
44template <>
45DUCKDB_API duckdb::string_t StringCast::Operation(uint64_t input, Vector &result);
46template <>
47DUCKDB_API duckdb::string_t StringCast::Operation(hugeint_t input, Vector &result);
48template <>
49DUCKDB_API duckdb::string_t StringCast::Operation(float input, Vector &result);
50template <>
51DUCKDB_API duckdb::string_t StringCast::Operation(double input, Vector &result);
52template <>
53DUCKDB_API duckdb::string_t StringCast::Operation(interval_t input, Vector &result);
54template <>
55DUCKDB_API duckdb::string_t StringCast::Operation(duckdb::string_t input, Vector &result);
56template <>
57DUCKDB_API duckdb::string_t StringCast::Operation(date_t input, Vector &result);
58template <>
59DUCKDB_API duckdb::string_t StringCast::Operation(dtime_t input, Vector &result);
60template <>
61DUCKDB_API duckdb::string_t StringCast::Operation(timestamp_t input, Vector &result);
62
63//! Temporary casting for Time Zone types. TODO: turn casting into functions.
64struct StringCastTZ {
65 template <typename SRC>
66 static inline string_t Operation(SRC input, Vector &vector) {
67 return StringCast::Operation(input, vector);
68 }
69};
70
71template <>
72duckdb::string_t StringCastTZ::Operation(date_t input, Vector &result);
73template <>
74duckdb::string_t StringCastTZ::Operation(dtime_t input, Vector &result);
75template <>
76duckdb::string_t StringCastTZ::Operation(timestamp_t input, Vector &result);
77
78} // namespace duckdb
79