MySQL++ Reference Manual

- Main Page
- Classes
- Files

- File List
- File Members

# 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, and
    00009  (c) 2004-2008 by Educational Technology Resources, Inc.  Others may
    00010  also hold copyrights on code in this file.  See the CREDITS.txt file
    00011  in the top directory of the distribution for details.
    00012
    00013  This file is part of MySQL++.
    00014
    00015  MySQL++ is free software; you can redistribute it and/or modify it
    00016  under the terms of the GNU Lesser General Public License as published
    00017  by the Free Software Foundation; either version 2.1 of the License, or
    00018  (at your option) any later version.
    00019
    00020  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00021  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00022  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00023  License for more details.
    00024
    00025  You should have received a copy of the GNU Lesser General Public
    00026  License along with MySQL++; if not, write to the Free Software
    00027  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00028  USA
    00029 ***********************************************************************/
    00030
    00031 #if !defined(MYSQLPP_COMMON_H)
    00032 #define MYSQLPP_COMMON_H
    00033
    00034 #if !defined(DOXYGEN_IGNORE)
    00035 // Doxygen will not generate documentation for the following stuff.
    00036
    00037 // Enable SSQLS by default.  Turned off below on platforms where we
    00038 // know it doesn't work.
    00039 #define MYSQLPP_SSQLS_COMPATIBLE
    00040
    00041 // For all platforms but Visual C++ 2003, the following macro is just
    00042 // an alias for "*this".  It needs a more complicated definition on
    00043 // VC++ 2003 to work around an error in the overloaded operator lookup
    00044 // logic.  For an explanation of the problem, see:
    00045 // http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
    00046 #define MYSQLPP_QUERY_THISPTR *this
    00047
    00048 // Work out major platform-specific stuff here.
    00049 #if defined(__WIN32__) || defined(_WIN32)
    00050 #       define MYSQLPP_PLATFORM_WINDOWS
    00051
    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 #else
    00109         // If not Windows, we assume some sort of Unixy build environment,
    00110         // where autotools is used.  (This includes Cygwin!)  #include the
    00111         // config.h file only if this file was included from a non-header
    00112         // file, because headers must not be dependent on config.h.
    00113 #       if defined(MYSQLPP_NOT_HEADER)
    00114 #               include "config.h"
    00115 #       endif
    00116
    00117         // Make DLL stuff a no-op on this platform.
    00118         #define MYSQLPP_EXPORT
    00119 #endif
    00120
    00121 #if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
    00122 #       include <mysql/mysql_version.h>
    00123 #else
    00124 #       include <mysql_version.h>
    00125 #endif
    00126
    00127 namespace mysqlpp {
    00128
    00131 const bool use_exceptions = true;
    00132
    00134 enum sql_cmp_type { sql_use_compare };
    00135
    00136 #if !defined(DOXYGEN_IGNORE)
    00137 // Figure out how to get large integer support on this system.  Suppress
    00138 // refman documentation for these typedefs, as they're system-dependent.
    00139 #if defined(MYSQLPP_NO_LONG_LONGS)
    00140 // Alias "longlong" and "ulonglong" to the regular "long" counterparts
    00141 typedef unsigned long ulonglong;
    00142 typedef long longlong;
    00143 #elif defined(_MSC_VER)
    00144 // It's VC++, so we'll use Microsoft's 64-bit integer types
    00145 typedef unsigned __int64 ulonglong;
    00146 typedef __int64 longlong;
    00147 #else
    00148 // No better idea, so assume the C99 convention.  If your compiler
    00149 // doesn't support this, please provide a patch to extend this ifdef, or
    00150 // define MYSQLPP_NO_LONG_LONGS.
    00151 typedef unsigned long long ulonglong;
    00152 typedef long long longlong;
    00153 #endif
    00154 #endif // !defined(DOXYGEN_IGNORE)
    00155
    00156 #if !defined(MYSQLPP_NO_UNSIGNED_INT_TYPES)
    00162 typedef unsigned long ulong;
    00163 #endif
    00164
    00165 } // end namespace mysqlpp
    00166
    00167 // The MySQL headers define these macros, which is completely wrong in a
    00168 // C++ project.  Undo the damage.
    00169 #undef min
    00170 #undef max
    00171
    00172 #endif // !defined(DOXYGEN_IGNORE)
    00173
    00174
    00175 // Now that we've defined all the stuff above, we can pull in the full
    00176 // MySQL header.  Basically, the above largely replaces MySQL's my_global.h
    00177 // while actually working with C++.  This is why we disobey the MySQL
    00178 // developer docs, which recommend including my_global.h before mysql.h.
    00179 #if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
    00180 #       include <mysql/mysql.h>
    00181 #else
    00182 #       include <mysql.h>
    00183 #endif
    00184
    00185 #endif // !defined(MYSQLPP_COMMON_H)