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 | |
16 | namespace duckdb { |
17 | |
18 | //! StringCast |
19 | class Vector; |
20 | |
21 | struct 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 | |
28 | template <> |
29 | DUCKDB_API duckdb::string_t StringCast::Operation(bool input, Vector &result); |
30 | template <> |
31 | DUCKDB_API duckdb::string_t StringCast::Operation(int8_t input, Vector &result); |
32 | template <> |
33 | DUCKDB_API duckdb::string_t StringCast::Operation(int16_t input, Vector &result); |
34 | template <> |
35 | DUCKDB_API duckdb::string_t StringCast::Operation(int32_t input, Vector &result); |
36 | template <> |
37 | DUCKDB_API duckdb::string_t StringCast::Operation(int64_t input, Vector &result); |
38 | template <> |
39 | DUCKDB_API duckdb::string_t StringCast::Operation(uint8_t input, Vector &result); |
40 | template <> |
41 | DUCKDB_API duckdb::string_t StringCast::Operation(uint16_t input, Vector &result); |
42 | template <> |
43 | DUCKDB_API duckdb::string_t StringCast::Operation(uint32_t input, Vector &result); |
44 | template <> |
45 | DUCKDB_API duckdb::string_t StringCast::Operation(uint64_t input, Vector &result); |
46 | template <> |
47 | DUCKDB_API duckdb::string_t StringCast::Operation(hugeint_t input, Vector &result); |
48 | template <> |
49 | DUCKDB_API duckdb::string_t StringCast::Operation(float input, Vector &result); |
50 | template <> |
51 | DUCKDB_API duckdb::string_t StringCast::Operation(double input, Vector &result); |
52 | template <> |
53 | DUCKDB_API duckdb::string_t StringCast::Operation(interval_t input, Vector &result); |
54 | template <> |
55 | DUCKDB_API duckdb::string_t StringCast::Operation(duckdb::string_t input, Vector &result); |
56 | template <> |
57 | DUCKDB_API duckdb::string_t StringCast::Operation(date_t input, Vector &result); |
58 | template <> |
59 | DUCKDB_API duckdb::string_t StringCast::Operation(dtime_t input, Vector &result); |
60 | template <> |
61 | DUCKDB_API duckdb::string_t StringCast::Operation(timestamp_t input, Vector &result); |
62 | |
63 | //! Temporary casting for Time Zone types. TODO: turn casting into functions. |
64 | struct StringCastTZ { |
65 | template <typename SRC> |
66 | static inline string_t Operation(SRC input, Vector &vector) { |
67 | return StringCast::Operation(input, vector); |
68 | } |
69 | }; |
70 | |
71 | template <> |
72 | duckdb::string_t StringCastTZ::Operation(date_t input, Vector &result); |
73 | template <> |
74 | duckdb::string_t StringCastTZ::Operation(dtime_t input, Vector &result); |
75 | template <> |
76 | duckdb::string_t StringCastTZ::Operation(timestamp_t input, Vector &result); |
77 | |
78 | } // namespace duckdb |
79 | |