1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
7 */
8
9#ifndef _SQL_CAST_H_
10#define _SQL_CAST_H_
11
12#define CAST_INTEGER_2_NUMERIC_2(T1,T2) \
13sql5_export str T1##_dec2_##T2(T2 *res, const int *s1, const T1 *v); \
14sql5_export str bat##T1##_dec2_##T2(bat *res, const int *s1, const bat *v); \
15sql5_export str T1##_dec2dec_##T2(T2 *res, const int *S1, const T1 *v, const int *d2, const int *S2); \
16sql5_export str bat##T1##_dec2dec_##T2(bat *res, const int *S1, const bat *v, const int *d2, const int *S2); \
17sql5_export str T1##_num2dec_##T2(T2 *res, const T1 *v, const int *d2, const int *s2); \
18sql5_export str bat##T1##_num2dec_##T2(bat *res, const bat *v, const int *d2, const int *s2);
19
20#ifdef HAVE_HGE
21#define CAST_INTEGER_2_NUMERIC_2_hge(T1) CAST_INTEGER_2_NUMERIC_2(T1,hge)
22#else
23#define CAST_INTEGER_2_NUMERIC_2_hge(T1)
24#endif
25
26#define CAST_INTEGER_2_NUMERIC_1(T1) \
27CAST_INTEGER_2_NUMERIC_2(T1,bte) \
28CAST_INTEGER_2_NUMERIC_2(T1,sht) \
29CAST_INTEGER_2_NUMERIC_2(T1,int) \
30CAST_INTEGER_2_NUMERIC_2(T1,lng) \
31CAST_INTEGER_2_NUMERIC_2_hge(T1) \
32CAST_INTEGER_2_NUMERIC_2(T1,flt) \
33CAST_INTEGER_2_NUMERIC_2(T1,dbl)
34
35CAST_INTEGER_2_NUMERIC_1(bte)
36CAST_INTEGER_2_NUMERIC_1(sht)
37CAST_INTEGER_2_NUMERIC_1(int)
38CAST_INTEGER_2_NUMERIC_1(lng)
39#ifdef HAVE_HGE
40CAST_INTEGER_2_NUMERIC_1(hge)
41#endif
42
43
44#define CAST_FLOATINGPOINT_2_INTEGER_2(T1,T2) \
45sql5_export str T1##_num2dec_##T2(T2 *res, const T1 *v, const int *d2, const int *s2); \
46sql5_export str bat##T1##_num2dec_##T2(bat *res, const bat *v, const int *d2, const int *s2);
47
48#ifdef HAVE_HGE
49#define CAST_FLOATINGPOINT_2_INTEGER_2_hge(T1) CAST_FLOATINGPOINT_2_INTEGER_2(T1,hge)
50#else
51#define CAST_FLOATINGPOINT_2_INTEGER_2_hge(T1)
52#endif
53
54#define CAST_FLOATINGPOINT_2_INTEGER_1(T1) \
55CAST_FLOATINGPOINT_2_INTEGER_2(T1,bte) \
56CAST_FLOATINGPOINT_2_INTEGER_2(T1,sht) \
57CAST_FLOATINGPOINT_2_INTEGER_2(T1,int) \
58CAST_FLOATINGPOINT_2_INTEGER_2(T1,lng) \
59CAST_FLOATINGPOINT_2_INTEGER_2_hge(T1)
60
61CAST_FLOATINGPOINT_2_INTEGER_1(flt)
62CAST_FLOATINGPOINT_2_INTEGER_1(dbl)
63
64#endif /* _SQL_CAST_H_ */
65