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

Generated on Tue Apr 17 08:42:13 2007 for MySQL++ by doxygen 1.3.5