# common.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007 /***********************************************************************
    00008  Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB,
    00009  (c) 2004-2009 by Educational Technology Resources, Inc., and
    00010  (c) 2009 by Warren Young.  Others may also hold copyrights on code
    00011  in this file.  See the CREDITS.txt file in the top directory of the
    00012  distribution for details.
    00013
    00014  This file is part of MySQL++.
    00015
    00016  MySQL++ is free software; you can redistribute it and/or modify it
    00017  under the terms of the GNU Lesser General Public License as published
    00018  by the Free Software Foundation; either version 2.1 of the License, or
    00019  (at your option) any later version.
    00020
    00021  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00022  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00023  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00024  License for more details.
    00025
    00026  You should have received a copy of the GNU Lesser General Public
    00027  License along with MySQL++; if not, write to the Free Software
    00028  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00029  USA
    00030 ***********************************************************************/
    00031
    00032 #if !defined(MYSQLPP_COMMON_H)
    00033 #define MYSQLPP_COMMON_H
    00034
    00035 #if !defined(DOXYGEN_IGNORE)
    00036 // Doxygen will not generate documentation for the following stuff.
    00037
    00038 // Enable SSQLS by default.  Turned off below on platforms where we
    00039 // know it doesn't work.
    00040 #define MYSQLPP_SSQLS_COMPATIBLE
    00041
    00042 // For all platforms but Visual C++ 2003, the following macro is just
    00043 // an alias for "*this".  It needs a more complicated definition on
    00044 // VC++ 2003 to work around an error in the overloaded operator lookup
    00045 // logic.  For an explanation of the problem, see:
    00046 // http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
    00047 #define MYSQLPP_QUERY_THISPTR *this
    00048
    00049 // Work out major platform-specific stuff here.
    00050 #if defined(__WIN32__) || defined(_WIN32)
    00051 #       define MYSQLPP_PLATFORM_WINDOWS
    00052         // Windows compiler support.  Tested with Microsoft Visual C++,
    00053         // Borland C++ Builder, and MinGW GCC.
    00054 #       include <winsock.h>
    00055
    00056         // Stuff for Visual C++ only
    00057 #       if defined(_MSC_VER)
    00058 #               define MYSQLPP_PLATFORM_VISUAL_CPP
    00059                 // MS *still* doesn't ship stdint.h, through VC++ 2008 at least.
    00060                 // This means we have to take a wild guess at appropriate
    00061                 // integer types in lib/sql_types.h.  See test/inttypes.cpp for
    00062                 // tests that check whether we've guessed well.
    00063 #               define MYSQLPP_NO_STDINT_H
    00064 #               if _MSC_VER < 1400
    00065                         // Workarounds for limitations of VC++ 2003 that are fixed
    00066                         // in 2005 and later.
    00067 #                       undef MYSQLPP_QUERY_THISPTR
    00068 #                       define MYSQLPP_QUERY_THISPTR dynamic_cast<std::ostream&>(*this)
    00069 #                       undef MYSQLPP_SSQLS_COMPATIBLE
    00070 #               elif !defined(_STLP_VERSION) && !defined(_STLP_VERSION_STR)
    00071                         // VC++ 2005 or newer and not using STLport, so #define
    00072                         // portability flags indicating features we can use from
    00073                         // the compiler's native RTL.
    00074 #                       define MYSQLPP_HAVE_LOCALTIME_S
    00075 #                       define MYSQLPP_HAVE_STD__NOINIT
    00076 #               endif
    00077
    00078                 // Disable complaints about STL data members: VC++ believes
    00079                 // these need to be __declspec(dllexport) for some reason.
    00080 #               pragma warning(disable: 4251)
    00081                 // Disable complaint that VC++ doesn't grok throw specs
    00082 #               pragma warning(disable: 4290)
    00083                 // Disable whining about using 'this' as a member initializer on VC++.
    00084 #               pragma warning(disable: 4355)
    00085                 // Disable whining about implicit conversions to bool
    00086 #               pragma warning(disable: 4800)
    00087                 // Disable nagging about new "secure" functions like strncpy_s()
    00088 #               pragma warning(disable: 4996)
    00089                 // Call _snprintf() for VC++ version of snprintf() function
    00090 #               define snprintf _snprintf
    00091 #       endif
    00092
    00093         // Define DLL import/export tags for Windows compilers, where we build
    00094         // the library into a DLL, for LGPL license compatibility reasons.
    00095         // (This is based on a similar mechanism in wxWindows.)
    00096
    00097         #ifdef MYSQLPP_MAKING_DLL
    00098                 // When making the DLL, export tagged symbols, so they appear
    00099                 // in the import library.
    00100                 #define MYSQLPP_EXPORT __declspec(dllexport)
    00101         #elif !defined(MYSQLPP_NO_DLL)
    00102                 // We must be _using_ the DLL, so import symbols instead.
    00103                 #define MYSQLPP_EXPORT __declspec(dllimport)
    00104         #else
    00105                 // Not making a DLL at all, so no-op these declspecs
    00106                 #define MYSQLPP_EXPORT
    00107         #endif
    00108
    00109         // We need to use the DOS/Windows path separator here
    00110         #define MYSQLPP_PATH_SEPARATOR '\\'
    00111 #else
    00112         // If not VC++, MinGW, or Xcode, we assume we're on a system using
    00113         // autoconf, so bring in the config.h file it wrote containing the
    00114         // config test results.  Only do this during the library build, and
    00115         // even then, not if included from a MySQL++ header file, since
    00116         // config.h cannot be safely installed with the other headers.
    00117 #       if defined(MYSQLPP_NOT_HEADER) && !defined(MYSQLPP_XCODE)
    00118 #               include "config.h"
    00119 #       endif
    00120
    00121         // Make DLL stuff a no-op on this platform.
    00122         #define MYSQLPP_EXPORT
    00123
    00124         // Assume POSIX path separator
    00125         #define MYSQLPP_PATH_SEPARATOR '/'
    00126 #endif
    00127
    00128 #if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
    00129 #       include <mysql/mysql_version.h>
    00130 #else
    00131 #       include <mysql_version.h>
    00132 #endif
    00133
    00134 namespace mysqlpp {
    00135
    00138 const bool use_exceptions = true;
    00139
    00141 enum sql_cmp_type { sql_use_compare };
    00142
    00143 #if !defined(DOXYGEN_IGNORE)
    00144 // Figure out how to get large integer support on this system.  Suppress
    00145 // refman documentation for these typedefs, as they're system-dependent.
    00146 #if defined(MYSQLPP_NO_LONG_LONGS)
    00147 // Alias "longlong" and "ulonglong" to the regular "long" counterparts
    00148 typedef unsigned long ulonglong;
    00149 typedef long longlong;
    00150 #elif defined(_MSC_VER)
    00151 // It's VC++, so we'll use Microsoft's 64-bit integer types
    00152 typedef unsigned __int64 ulonglong;
    00153 typedef __int64 longlong;
    00154 #else
    00155 // No better idea, so assume the C99 convention.  If your compiler
    00156 // doesn't support this, please provide a patch to extend this ifdef, or
    00157 // define MYSQLPP_NO_LONG_LONGS.
    00158 typedef unsigned long long ulonglong;
    00159 typedef long long longlong;
    00160 #endif
    00161 #endif // !defined(DOXYGEN_IGNORE)
    00162
    00163 #if !defined(MYSQLPP_NO_UNSIGNED_INT_TYPES)
    00169 typedef unsigned long ulong;
    00170 #endif
    00171
    00172 } // end namespace mysqlpp
    00173
    00174 // The MySQL headers define these macros, which is completely wrong in a
    00175 // C++ project.  Undo the damage.
    00176 #undef min
    00177 #undef max
    00178
    00179 #endif // !defined(DOXYGEN_IGNORE)
    00180
    00181
    00182 // Now that we've defined all the stuff above, we can pull in the full
    00183 // MySQL header.  Basically, the above largely replaces MySQL's my_global.h
    00184 // while actually working with C++.  This is why we disobey the MySQL
    00185 // developer docs, which recommend including my_global.h before mysql.h.
    00186 #if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
    00187 #       include <mysql/mysql.h>
    00188 #else
    00189 #       include <mysql.h>
    00190 #endif
    00191
    00192 #endif // !defined(MYSQLPP_COMMON_H)