odbc++/setup.h

00001 /*
00002    This file is part of libodbc++.
00003 
00004    Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef __ODBCXX_SETUP_H
00023 #define __ODBCXX_SETUP_H
00024 
00025 #if defined(__WIN32__) && !defined(WIN32)
00026 # define WIN32 1
00027 #endif
00028 
00029 #if !defined(WIN32)
00030 # include <odbc++/config.h>
00031 #else
00032 # include <odbc++/config-win32.h>
00033 #endif
00034 
00035 
00036 #if defined(IN_ODBCXX) && defined(ODBCXX_ENABLE_THREADS)
00037 # if !defined(_REENTRANT)
00038 #  define _REENTRANT 1
00039 # endif
00040 # if !defined(_THREAD_SAFE)
00041 #  define _THREAD_SAFE 1
00042 # endif
00043 #endif
00044 
00045 // set the UNICODE define activate wide versions of ODBC functions
00046 #if defined(ODBCXX_UNICODE)
00047 # if !defined(UNICODE)
00048 #  define UNICODE
00049 # endif
00050 #else
00051 # if defined(UNICODE)
00052 #  undef UNICODE
00053 # endif
00054 #endif
00055 
00056 // check whether we use strstream or stringstream
00057 #if defined(IN_ODBCXX)
00058 # if defined(ODBCXX_UNICODE)
00059 #   define ODBCXX_SSTREAM std::wstringstream
00060 # else
00061 # if defined(ODBCXX_HAVE_SSTREAM)
00062 #  define ODBCXX_SSTREAM std::stringstream
00063 # else
00064 #  define ODBCXX_SSTREAM std::strstream
00065 # endif
00066 # endif
00067 #endif
00068 
00069 // check if ODBCVER is forced to something
00070 #if defined(ODBCXX_ODBCVER)
00071 # define ODBCVER ODBCXX_ODBCVER
00072 #endif
00073 
00074 // this can confuse our Types::CHAR
00075 #ifdef CHAR
00076 #undef CHAR
00077 #endif
00078 
00079 // NDEBUG and cassert
00080 #if defined(IN_ODBCXX)
00081 # if !defined(ODBCXX_DEBUG)
00082 #  define NDEBUG
00083 # endif
00084 # include <cassert>
00085 #endif
00086 
00087 // this should do the trick
00088 #if defined(__GNUC__) && __GNUC__>=3
00089 # define ODBCXX_HAVE_ISO_CXXLIB
00090 #endif
00091 
00092 
00093 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
00094 # if defined(ODBCXX_DLL)
00095 #  if defined(IN_ODBCXX)
00096 #   define ODBCXX_EXPORT __declspec(dllexport)
00097 #  else
00098 #   define ODBCXX_EXPORT __declspec(dllimport)
00099 #  endif
00100 # endif
00101 #endif
00102 
00103 #if !defined(ODBCXX_EXPORT)
00104 # define ODBCXX_EXPORT
00105 #endif
00106 
00107 #if defined(_MSC_VER) || defined(__MINGW32__)
00108 # define ODBCXX_DUMMY_RETURN(x) return (x)
00109 #else
00110 # define ODBCXX_DUMMY_RETURN(x) ((void)0)
00111 #endif
00112 
00113 
00114 // environment abstractions
00115 
00116 #if defined(ODBCXX_QT)
00117 
00118 # define ODBCXX_STRING QString
00119 # define ODBCXX_STRING_C(s) QString::fromLocal8Bit(s)
00120 # define ODBCXX_STRING_CL(s,l) QString::fromLocal8Bit(s,l)
00121 # define ODBCXX_STRING_LEN(s) s.length()
00122 # define ODBCXX_STRING_DATA(s) s.local8Bit().data()
00123 # define ODBCXX_STRING_CSTR(s) s.local8Bit().data()
00124 
00125 # define ODBCXX_STREAM QIODevice
00126 
00127 # define ODBCXX_BYTES QByteArray
00128 # define ODBCXX_BYTES_SIZE(b) b.size()
00129 # define ODBCXX_BYTES_DATA(b) b.data()
00130 # define ODBCXX_BYTES_C(buf,len) QByteArray().duplicate(buf,len)
00131 
00132 #else
00133 
00134 # if defined(ODBCXX_UNICODE)
00135 
00136 #  define ODBCXX_STRING std::wstring
00137 #  define ODBCXX_STRING_C(s) std::wstring(s)
00138 #  define ODBCXX_STRING_CL(s,l) std::wstring(s,l)
00139 #  define ODBCXX_STRING_LEN(s) s.length()
00140 #  define ODBCXX_STRING_DATA(s) s.data()
00141 #  define ODBCXX_STRING_CSTR(s) s.c_str()
00142 
00143 #  define ODBCXX_STREAM std::wistream
00144 #  define ODBCXX_STREAMBUF std::wstreambuf
00145 
00146 #  define ODBCXX_BYTES odbc::Bytes
00147 #  define ODBCXX_BYTES_SIZE(b) b.getSize()
00148 #  define ODBCXX_BYTES_DATA(b) b.getData()
00149 #  define ODBCXX_BYTES_C(buf,len) odbc::Bytes((wchar_t*)buf,(size_t)len)
00150 
00151 # else
00152 
00153 #  define ODBCXX_STRING std::string
00154 #  define ODBCXX_STRING_C(s) std::string(s)
00155 #  define ODBCXX_STRING_CL(s,l) std::string(s,l)
00156 #  define ODBCXX_STRING_LEN(s) s.length()
00157 #  define ODBCXX_STRING_DATA(s) s.data()
00158 #  define ODBCXX_STRING_CSTR(s) s.c_str()
00159 
00160 #  define ODBCXX_STREAM std::istream
00161 #  define ODBCXX_STREAMBUF std::streambuf
00162 
00163 #  define ODBCXX_BYTES odbc::Bytes
00164 #  define ODBCXX_BYTES_SIZE(b) b.getSize()
00165 #  define ODBCXX_BYTES_DATA(b) b.getData()
00166 #  define ODBCXX_BYTES_C(buf,len) odbc::Bytes((signed char*)buf,(size_t)len)
00167 
00168 # endif // ODBCXX_UNICODE
00169 
00170 #endif // ODBCXX_QT
00171 
00172 #if defined(ODBCXX_UNICODE)
00173 # define ODBCXX_CHAR_TYPE wchar_t
00174 # define ODBCXX_SIGNED_CHAR_TYPE wchar_t
00175 # define ODBCXX_SQLCHAR SQLWCHAR
00176 # define ODBCXX_STRING_CONST(s) L ## s
00177 # define ODBCXX_COUT std::wcout
00178 # define ODBCXX_CERR std::wcerr
00179 # define ODBCXX_STRTOL wcstol
00180 #else
00181 # define ODBCXX_CHAR_TYPE char
00182 # define ODBCXX_SIGNED_CHAR_TYPE signed char
00183 # define ODBCXX_SQLCHAR SQLCHAR
00184 # define ODBCXX_STRING_CONST(s) s
00185 # define ODBCXX_COUT std::cout
00186 # define ODBCXX_CERR std::cerr
00187 # define ODBCXX_STRTOL strtol
00188 #endif
00189 
00190 #endif // __ODBCXX_SETUP_H

Go back to the libodbc++ homepage