Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

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 environment variable to activate wide versions
00046 // of ODBC functions
00047 #if defined(ODBCXX_UNICODE)
00048 # if !defined(UNICODE)
00049 #  define UNICODE
00050 # endif
00051 #else
00052 # if defined(UNICODE)
00053 #  undef UNICODE
00054 # endif
00055 #endif
00056 
00057 // check whether we use strstream or stringstream
00058 #if defined(IN_ODBCXX)
00059 # if defined(ODBCXX_UNICODE)
00060 #   define ODBCXX_SSTREAM std::wstringstream
00061 # else
00062 # if defined(ODBCXX_HAVE_SSTREAM)
00063 #  define ODBCXX_SSTREAM std::stringstream
00064 # else
00065 #  define ODBCXX_SSTREAM std::strstream
00066 # endif
00067 # endif
00068 #endif
00069 
00070 // check if ODBCVER is forced to something
00071 #if defined(ODBCXX_ODBCVER)
00072 # define ODBCVER ODBCXX_ODBCVER
00073 #endif
00074 
00075 // this can confuse our Types::CHAR
00076 #ifdef CHAR
00077 #undef CHAR
00078 #endif
00079 
00080 // NDEBUG and cassert
00081 #if defined(IN_ODBCXX)
00082 # if !defined(ODBCXX_DEBUG)
00083 #  define NDEBUG
00084 # endif
00085 # include <cassert>
00086 #endif
00087 
00088 // this should do the trick
00089 #if defined(__GNUC__) && __GNUC__>=3
00090 # define ODBCXX_HAVE_ISO_CXXLIB
00091 #endif
00092 
00093 
00094 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
00095 # if defined(ODBCXX_DLL)
00096 #  if defined(IN_ODBCXX)
00097 #   define ODBCXX_EXPORT __declspec(dllexport)
00098 #  else
00099 #   define ODBCXX_EXPORT __declspec(dllimport)
00100 #  endif
00101 # endif
00102 #endif
00103 
00104 #if !defined(ODBCXX_EXPORT)
00105 # define ODBCXX_EXPORT
00106 #endif
00107 
00108 #if defined(_MSC_VER) || defined(__MINGW32__)
00109 # define ODBCXX_DUMMY_RETURN(x) return (x)
00110 #else
00111 # define ODBCXX_DUMMY_RETURN(x) ((void)0)
00112 #endif
00113 
00114 
00115 // environment abstractions
00116 
00117 #if defined(ODBCXX_QT)
00118 
00119 # define ODBCXX_STRING QString
00120 # define ODBCXX_STRING_C(s) QString::fromLocal8Bit(s)
00121 # define ODBCXX_STRING_CL(s,l) QString::fromLocal8Bit(s,l)
00122 # define ODBCXX_STRING_LEN(s) s.length()
00123 # define ODBCXX_STRING_DATA(s) s.local8Bit().data()
00124 # define ODBCXX_STRING_CSTR(s) s.local8Bit().data()
00125 
00126 # define ODBCXX_STREAM QIODevice
00127 
00128 # define ODBCXX_BYTES QByteArray
00129 # define ODBCXX_BYTES_SIZE(b) b.size()
00130 # define ODBCXX_BYTES_DATA(b) b.data()
00131 # define ODBCXX_BYTES_C(buf,len) QByteArray().duplicate(buf,len)
00132 
00133 #else
00134 
00135 # if defined(ODBCXX_UNICODE)
00136 
00137 #  define ODBCXX_STRING std::wstring
00138 #  define ODBCXX_STRING_C(s) std::wstring(s)
00139 #  define ODBCXX_STRING_CL(s,l) std::wstring(s,l)
00140 #  define ODBCXX_STRING_LEN(s) s.length()
00141 #  define ODBCXX_STRING_DATA(s) s.data()
00142 #  define ODBCXX_STRING_CSTR(s) s.c_str()
00143 
00144 #  define ODBCXX_STREAM std::wistream
00145 #  define ODBCXX_STREAMBUF std::wstreambuf
00146 
00147 #  define ODBCXX_BYTES odbc::Bytes
00148 #  define ODBCXX_BYTES_SIZE(b) b.getSize()
00149 #  define ODBCXX_BYTES_DATA(b) b.getData()
00150 #  define ODBCXX_BYTES_C(buf,len) odbc::Bytes((wchar_t*)buf,(size_t)len)
00151 
00152 # else
00153 
00154 # define ODBCXX_STRING std::string
00155 # define ODBCXX_STRING_C(s) std::string(s)
00156 # define ODBCXX_STRING_CL(s,l) std::string(s,l)
00157 # define ODBCXX_STRING_LEN(s) s.length()
00158 # define ODBCXX_STRING_DATA(s) s.data()
00159 # define ODBCXX_STRING_CSTR(s) s.c_str()
00160 
00161 # define ODBCXX_STREAM std::istream
00162 #  define ODBCXX_STREAMBUF std::streambuf
00163 
00164 # define ODBCXX_BYTES odbc::Bytes
00165 # define ODBCXX_BYTES_SIZE(b) b.getSize()
00166 # define ODBCXX_BYTES_DATA(b) b.getData()
00167 # define ODBCXX_BYTES_C(buf,len) odbc::Bytes((signed char*)buf,(size_t)len)
00168 
00169 # endif // ODBCXX_UNICODE
00170 
00171 #endif // ODBCXX_QT
00172 
00173 #if defined(ODBCXX_UNICODE)
00174 # define ODBCXX_CHAR_TYPE wchar_t
00175 # define ODBCXX_SIGNED_CHAR_TYPE wchar_t
00176 # define ODBCXX_SQLCHAR SQLWCHAR
00177 # define ODBCXX_STRING_CONST(s) L ## s
00178 # define ODBCXX_COUT wcout
00179 # define ODBCXX_CERR wcerr
00180 # define ODBCXX_STRTOL wcstol
00181 #else
00182 # define ODBCXX_CHAR_TYPE char
00183 # define ODBCXX_SIGNED_CHAR_TYPE signed char
00184 # define ODBCXX_SQLCHAR SQLCHAR
00185 # define ODBCXX_STRING_CONST(s) s
00186 # define ODBCXX_COUT cout
00187 # define ODBCXX_CERR cerr
00188 # define ODBCXX_STRTOL strtol
00189 #endif
00190 
00191 #endif // __ODBCXX_SETUP_H

Go back to the freeodbc++ homepage