libodbc++  0.2.5
setup.h
1 /*
2  This file is part of libodbc++.
3 
4  Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING. If not, write to
18  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  Boston, MA 02111-1307, USA.
20 */
21 
22 #ifndef __ODBCXX_SETUP_H
23 #define __ODBCXX_SETUP_H
24 
25 #if defined(__WIN32__) && !defined(WIN32)
26 # define WIN32 1
27 #endif
28 
29 #if !defined(WIN32)
30 # include <odbc++/config.h>
31 # define ODBCXX_OPERATOR_NEW new
32 # define ODBCXX_OPERATOR_DELETE delete
33 # define ODBCXX_OPERATOR_NEW_DEBUG(debFile, debLine) new
34 # define ODBCXX_OPERATOR_DELETE_DEBUG(debFile, debLine) delete
35 #else
36 #if defined(_DEBUG) && defined(IN_ODBCXX)
37 void* operator new(size_t n, const char* debFile, int debLine);
38 void operator delete(void* p, const char* debFile, int debLine);
39 # define ODBCXX_OPERATOR_NEW new(__FILE__, __LINE__)
40 # define ODBCXX_OPERATOR_DELETE delete
41 # define ODBCXX_OPERATOR_NEW_DEBUG(debFile, debLine) new(debFile, debLine)
42 # define ODBCXX_OPERATOR_DELETE_DEBUG(debFile, debLine) delete
43 #else
44 # define OPERATOR_NEW new
45 # define OPERATOR_DELETE delete
46 # define ODBCXX_OPERATOR_NEW_DEBUG(debFile, debLine) new
47 # define ODBCXX_OPERATOR_DELETE_DEBUG(debFile, debLine) delete
48 #endif // _DEBUG
49 
50 
51 # include <odbc++/config-win32.h>
52 #endif // defined(__WIN32__) && !defined(WIN32)
53 
54 #define ODBCXX_DELETE_POINTER(x, debfile, debline)\
55  if(x != 0)\
56  { ODBCXX_OPERATOR_DELETE_DEBUG(debfile, debline) x;\
57  x = NULL;\
58  }
59 #define ODBCXX_DELETE_ARRPOINTER(x, debfile, debline)\
60  if(x != 0)\
61  { ODBCXX_OPERATOR_DELETE_DEBUG(debfile, debline)[] x;\
62  x = NULL;\
63  }
64 
65 
66 #if defined(IN_ODBCXX) && defined(ODBCXX_ENABLE_THREADS)
67 # if !defined(_REENTRANT)
68 # define _REENTRANT 1
69 # endif
70 # if !defined(_THREAD_SAFE)
71 # define _THREAD_SAFE 1
72 # endif
73 #endif
74 
75 // set the UNICODE define activate wide versions of ODBC functions
76 #if defined(ODBCXX_UNICODE)
77 # if !defined(UNICODE)
78 # define UNICODE
79 # endif
80 #else
81 # if defined(UNICODE)
82 # undef UNICODE
83 # endif
84 #endif
85 
86 // check whether we use strstream or stringstream
87 #if defined(ODBCXX_UNICODE)
88 # define ODBCXX_SSTREAM std::wstringstream
89 #else
90 # if defined(ODBCXX_HAVE_SSTREAM)
91 # define ODBCXX_SSTREAM std::stringstream
92 # else
93 # define ODBCXX_SSTREAM std::strstream
94 # endif
95 #endif
96 
97 // check if ODBCVER is forced to something
98 #if defined(ODBCXX_ODBCVER)
99 # define ODBCVER ODBCXX_ODBCVER
100 #endif
101 
102 // this can confuse our Types::CHAR
103 #ifdef CHAR
104 #undef CHAR
105 #endif
106 
107 // NDEBUG and cassert
108 #if defined(IN_ODBCXX)
109 # if !defined(ODBCXX_DEBUG)
110 # if !defined(NDEBUG)
111 # define NDEBUG
112 # endif
113 # endif
114 # include <cassert>
115 #endif
116 
117 // this should do the trick
118 #if defined(__GNUC__) && __GNUC__>=3
119 # define ODBCXX_HAVE_ISO_CXXLIB
120 #endif
121 
122 
123 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
124 # if defined(ODBCXX_DLL)
125 # if defined(IN_ODBCXX)
126 # define ODBCXX_EXPORT __declspec(dllexport)
127 # else
128 # define ODBCXX_EXPORT __declspec(dllimport)
129 # endif
130 # endif
131 #endif
132 
133 #if !defined(ODBCXX_EXPORT)
134 # define ODBCXX_EXPORT
135 #endif
136 
137 #if defined(_MSC_VER) || defined(__MINGW32__)
138 # define ODBCXX_DUMMY_RETURN(x) return (x)
139 #else
140 # define ODBCXX_DUMMY_RETURN(x) ((void)0)
141 #endif
142 
143 
144 // environment abstractions
145 
146 #if defined(ODBCXX_QT)
147 
148 # define ODBCXX_STRING QString
149 # define ODBCXX_STRING_C(s) QString::fromLocal8Bit(s)
150 # define ODBCXX_STRING_CL(s,l) QString::fromLocal8Bit(s,l)
151 # define ODBCXX_STRING_LEN(s) s.length()
152 # define ODBCXX_STRING_DATA(s) s.local8Bit().data()
153 # define ODBCXX_STRING_CSTR(s) s.local8Bit().data()
154 
155 # define ODBCXX_STREAM QIODevice
156 
157 # define ODBCXX_BYTES QByteArray
158 # define ODBCXX_BYTES_SIZE(b) b.size()
159 # define ODBCXX_BYTES_DATA(b) b.data()
160 # define ODBCXX_BYTES_C(buf,len) QByteArray().duplicate(buf,len)
161 
162 #else
163 
164 # if defined(ODBCXX_UNICODE)
165 
166 # define ODBCXX_STRING std::wstring
167 # define ODBCXX_STRING_C(s) std::wstring(s)
168 # define ODBCXX_STRING_CL(s,l) std::wstring(s,l)
169 # define ODBCXX_STRING_LEN(s) s.length()
170 # define ODBCXX_STRING_DATA(s) s.data()
171 # define ODBCXX_STRING_CSTR(s) s.c_str()
172 
173 # define ODBCXX_STREAM std::wistream
174 # define ODBCXX_STREAMBUF std::wstreambuf
175 
176 # define ODBCXX_BYTES odbc::Bytes
177 # define ODBCXX_BYTES_SIZE(b) b.getSize()
178 # define ODBCXX_BYTES_DATA(b) b.getData()
179 # define ODBCXX_BYTES_C(buf,len) odbc::Bytes((wchar_t*)buf,(size_t)len)
180 
181 # else
182 
183 # define ODBCXX_STRING std::string
184 # define ODBCXX_STRING_C(s) std::string(s)
185 # define ODBCXX_STRING_CL(s,l) std::string(s,l)
186 # define ODBCXX_STRING_LEN(s) s.length()
187 # define ODBCXX_STRING_DATA(s) s.data()
188 # define ODBCXX_STRING_CSTR(s) s.c_str()
189 
190 # define ODBCXX_STREAM std::istream
191 # define ODBCXX_STREAMBUF std::streambuf
192 
193 # define ODBCXX_BYTES odbc::Bytes
194 # define ODBCXX_BYTES_SIZE(b) b.getSize()
195 # define ODBCXX_BYTES_DATA(b) b.getData()
196 # define ODBCXX_BYTES_C(buf,len) odbc::Bytes((signed char*)buf,(size_t)len)
197 
198 # endif // ODBCXX_UNICODE
199 
200 #endif // ODBCXX_QT
201 
202 #if defined(ODBCXX_UNICODE)
203 # define ODBCXX_CHAR_TYPE wchar_t
204 # define ODBCXX_SIGNED_CHAR_TYPE wchar_t
205 # define ODBCXX_SQLCHAR SQLWCHAR
206 # define ODBCXX_STRING_CONST(s) L ## s
207 # define ODBCXX_COUT std::wcout
208 # define ODBCXX_CERR std::wcerr
209 # define ODBCXX_STRTOL wcstol
210 #else
211 # define ODBCXX_CHAR_TYPE char
212 # define ODBCXX_SIGNED_CHAR_TYPE signed char
213 # define ODBCXX_SQLCHAR SQLCHAR
214 # define ODBCXX_STRING_CONST(s) s
215 # define ODBCXX_COUT std::cout
216 # define ODBCXX_CERR std::cerr
217 # define ODBCXX_STRTOL strtol
218 #endif
219 
220 #endif // __ODBCXX_SETUP_H

Go back to the libodbc++ homepage