# 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, 2000 and 2001 by
    00009  MySQL AB, and (c) 2004-2007 by Educational Technology Resources, Inc.
    00010  Others may also hold copyrights on code in this file.  See the CREDITS
    00011  file 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 // Work out major platform-specific stuff here.
    00038 #if defined(__WIN32__) || defined(_WIN32)
    00039 #       define MYSQLPP_PLATFORM_WINDOWS
    00040
    00041         // Windows compiler support.  Tested with Microsoft Visual C++,
    00042         // Borland C++ Builder, and MinGW GCC.
    00043 #       include <winsock.h>
    00044
    00045         // Stuff for Visual C++ only
    00046 #       if defined(_MSC_VER)
    00047                 // Disable whining about using 'this' as a member initializer on VC++.
    00048 #               pragma warning(disable: 4355)
    00049                 // Disable whining about implicit conversions to bool
    00050 #               pragma warning(disable: 4800)
    00051                 // Disable nagging about new "secure" functions like strncpy_s()
    00052 #               pragma warning(disable: 4996)
    00053                 // Disable complaints about STL data members: VC++ believes
    00054                 // these need to be __declspec(dllexport) for some reason.
    00055 #               pragma warning(disable: 4251)
    00056                 // Call _snprintf() for VC++ version of snprintf() function
    00057 #               define snprintf _snprintf
    00058 #       endif
    00059
    00060         // Define DLL import/export tags for Windows compilers, where we build
    00061         // the library into a DLL, for LGPL license compatibility reasons.
    00062         // (This is based on a similar mechanism in wxWindows.)
    00063
    00064         #ifdef MYSQLPP_MAKING_DLL
    00065                 // When making the DLL, export tagged symbols, so they appear
    00066                 // in the import library.
    00067                 #define MYSQLPP_EXPORT __declspec(dllexport)
    00068         #elif !defined(MYSQLPP_NO_DLL)
    00069                 // We must be _using_ the DLL, so import symbols instead.
    00070                 #define MYSQLPP_EXPORT __declspec(dllimport)
    00071         #else
    00072                 // Not making a DLL at all, so no-op these declspecs
    00073                 #define MYSQLPP_EXPORT
    00074         #endif
    00075 #else
    00076         // If not Windows, we assume some sort of Unixy build environment,
    00077         // where autotools is used.  (This includes Cygwin!)  #include the
    00078         // config.h file only if this file was included from a non-header
    00079         // file, because headers must not be dependent on config.h.
    00080 #       if defined(MYSQLPP_NOT_HEADER)
    00081 #               include "config.h"
    00082 #       endif
    00083
    00084         // Make DLL stuff a no-op on this platform.
    00085         #define MYSQLPP_EXPORT
    00086 #endif
    00087
    00088 #if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
    00089 #       include <mysql/mysql_version.h>
    00090 #else
    00091 #       include <mysql_version.h>
    00092 #endif
    00093
    00094 namespace mysqlpp {
    00095
    00098 const bool use_exceptions = true;
    00099
    00101 enum sql_cmp_type { sql_use_compare };
    00102
    00103 #if !defined(DOXYGEN_IGNORE)
    00104 // Figure out how to get large integer support on this system.  Suppress
    00105 // refman documentation for these typedefs, as they're system-dependent.
    00106 #if defined(NO_LONG_LONGS)
    00107 // Alias "longlong" and "ulonglong" to the regular "long" counterparts
    00108 typedef unsigned long ulonglong;
    00109 typedef long longlong;
    00110 #elif defined(_MSC_VER)
    00111 // It's VC++, so we'll use Microsoft's 64-bit integer types
    00112 typedef unsigned __int64 ulonglong;
    00113 typedef __int64 longlong;
    00114 #else
    00115 // No better idea, so assume the C99 convention.  If your compiler
    00116 // doesn't support this, please provide a patch to extend this ifdef, or
    00117 // define NO_LONG_LONGS.
    00118 typedef unsigned long long ulonglong;
    00119 typedef long long longlong;
    00120 #endif
    00121 #endif // !defined(DOXYGEN_IGNORE)
    00122
    00124 typedef const char cchar;
    00125
    00126 #if !defined(MYSQLPP_NO_UNSIGNED_INT_TYPES)
    00127
    00128 typedef unsigned int uint;
    00130 typedef unsigned long ulong;
    00131 #endif
    00132
    00133 } // end namespace mysqlpp
    00134
    00135 // The MySQL headers define these macros, which is completely wrong in a
    00136 // C++ project.  Undo the damage.
    00137 #undef min
    00138 #undef max
    00139
    00140 #endif // !defined(DOXYGEN_IGNORE)
    00141
    00142
    00143 // Now that we've defined all the stuff above, we can pull in the full
    00144 // MySQL header.  Basically, the above largely replaces MySQL's my_global.h
    00145 // while actually working with C++.  This is why we disobey the MySQL
    00146 // developer docs, which recommend including my_global.h before mysql.h.
    00147 #if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
    00148 #       include <mysql/mysql.h>
    00149 #else
    00150 #       include <mysql.h>
    00151 #endif
    00152
    00153
    00154 namespace mysqlpp {
    00155
    00157 typedef MYSQL_FIELD Field;
    00158
    00159 } // end namespace mysqlpp
    00160
    00161 #endif // !defined(MYSQLPP_COMMON_H)