The OpenD Programming Language

1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
7  * Source: $(PHOBOSSRC etc/c/odbc/_sqltypes.d)
8 
9 Declarations for interfacing with the ODBC library.
10 
11 See_Also: $(LINK2 https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/odbc-api-reference,
12             ODBC API Reference on MSDN)
13  */
14 module etc.c.odbc.sqltypes;
15 
16 version (ANSI) {} else version = Unicode;
17 
18 /* Conversion notes:
19   It's assumed that ODBC >= 0x0300.
20 */
21 
22 // Import windows types or declare appropriate aliases if we are not.
23 version (Windows)
24 {
25     public import core.sys.windows.windef;
26     public import core.sys.windows.basetyps; // for GUID
27 }
28 else
29 {
30     alias ushort USHORT, WORD;
31     alias uint ULONG, LONG, BOOL, DWORD;
32     alias void VOID;
33     alias void* PVOID, HANDLE, HWND;
34     alias ubyte UCHAR, BYTE;
35     alias wchar* LPWSTR;
36 
37     align(1) struct GUID {  // size is 16
38         align(1):
39         DWORD   Data1;
40         WORD    Data2;
41         WORD    Data3;
42         BYTE[8] Data4;
43     }
44 }
45 alias GUID SQLGUID;
46 
47 alias byte SCHAR, SQLSCHAR;
48 alias int SDWORD, SLONG, SQLINTEGER;
49 alias short SWORD, SSHORT, RETCODE, SQLSMALLINT;
50 alias ULONG UDWORD;
51 alias USHORT UWORD, SQLUSMALLINT;
52 alias double SDOUBLE, LDOUBLE;
53 alias float SFLOAT;
54 alias PVOID PTR, HENV, HDBC, HSTMT, SQLPOINTER;
55 alias UCHAR SQLCHAR;
56 // #ifndef _WIN64
57 alias UDWORD SQLUINTEGER;
58 // #endif
59 
60 //static if (ODBCVER >= 0x0300)
61 //{
62 alias HANDLE SQLHANDLE;
63 alias SQLHANDLE SQLHENV, SQLHDBC, SQLHSTMT, SQLHDESC;
64 /*
65 }
66 else
67 {
68 alias void* SQLHENV;
69 alias void* SQLHDBC;
70 alias void* SQLHSTMT;
71 }
72 */
73 alias SQLSMALLINT SQLRETURN;
74 alias HWND SQLHWND;
75 alias ULONG BOOKMARK;
76 
77 alias SQLINTEGER SQLLEN, SQLROWOFFSET;
78 alias SQLUINTEGER SQLROWCOUNT, SQLULEN;
79 alias DWORD SQLTRANSID;
80 alias SQLUSMALLINT SQLSETPOSIROW;
81 alias wchar SQLWCHAR;
82 
83 version (Unicode)
84 {
85     alias SQLWCHAR SQLTCHAR;
86 }
87 else
88 {
89     alias SQLCHAR  SQLTCHAR;
90 }
91 //static if (ODBCVER >= 0x0300)
92 //{
93 alias ubyte  SQLDATE, SQLDECIMAL;
94 alias double SQLDOUBLE, SQLFLOAT;
95 alias ubyte  SQLNUMERIC;
96 alias float  SQLREAL;
97 alias ubyte  SQLTIME, SQLTIMESTAMP, SQLVARCHAR;
98 alias long   ODBCINT64, SQLBIGINT;
99 alias ulong  SQLUBIGINT;
100 //}
101 
102 struct DATE_STRUCT {
103     SQLSMALLINT year;
104     SQLUSMALLINT month;
105     SQLUSMALLINT day;
106 }
107 
108 struct TIME_STRUCT {
109     SQLUSMALLINT hour;
110     SQLUSMALLINT minute;
111     SQLUSMALLINT second;
112 }
113 
114 struct TIMESTAMP_STRUCT {
115     SQLSMALLINT year;
116     SQLUSMALLINT month;
117     SQLUSMALLINT day;
118     SQLUSMALLINT hour;
119     SQLUSMALLINT minute;
120     SQLUSMALLINT second;
121     SQLUINTEGER fraction;
122 }
123 
124 //static if (ODBCVER >= 0x0300)
125 //{
126 alias DATE_STRUCT SQL_DATE_STRUCT;
127 alias TIME_STRUCT SQL_TIME_STRUCT;
128 alias TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
129 
130 enum SQLINTERVAL {
131     SQL_IS_YEAR = 1,
132     SQL_IS_MONTH,
133     SQL_IS_DAY,
134     SQL_IS_HOUR,
135     SQL_IS_MINUTE,
136     SQL_IS_SECOND,
137     SQL_IS_YEAR_TO_MONTH,
138     SQL_IS_DAY_TO_HOUR,
139     SQL_IS_DAY_TO_MINUTE,
140     SQL_IS_DAY_TO_SECOND,
141     SQL_IS_HOUR_TO_MINUTE,
142     SQL_IS_HOUR_TO_SECOND,
143     SQL_IS_MINUTE_TO_SECOND
144 }
145 
146 struct SQL_YEAR_MONTH_STRUCT {
147     SQLUINTEGER year;
148     SQLUINTEGER month;
149 }
150 
151 struct SQL_DAY_SECOND_STRUCT {
152     SQLUINTEGER day;
153     SQLUINTEGER hour;
154     SQLUINTEGER minute;
155     SQLUINTEGER second;
156     SQLUINTEGER fraction;
157 }
158 
159 struct SQL_INTERVAL_STRUCT {
160     SQLINTERVAL interval_type;
161     SQLSMALLINT interval_sign;
162     union _intval {
163         SQL_YEAR_MONTH_STRUCT year_month;
164         SQL_DAY_SECOND_STRUCT day_second;
165     }
166     _intval intval;
167 }
168 
169 enum SQL_MAX_NUMERIC_LEN = 16;
170 
171 struct SQL_NUMERIC_STRUCT {
172     SQLCHAR precision;
173     SQLSCHAR scale;
174     SQLCHAR sign;
175     SQLCHAR[SQL_MAX_NUMERIC_LEN] val;
176 }
177 // } ODBCVER >= 0x0300