Main Page
Namespaces
Classes
Files
File List
File Members
common.h
Go to the documentation of this file.
1
7
/***********************************************************************
8
Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB,
9
(c) 2004-2009 by Educational Technology Resources, Inc., and
10
(c) 2009 by Warren Young. Others may also hold copyrights on code
11
in this file. See the CREDITS.txt file in the top directory of the
12
distribution for details.
13
14
This file is part of MySQL++.
15
16
MySQL++ is free software; you can redistribute it and/or modify it
17
under the terms of the GNU Lesser General Public License as published
18
by the Free Software Foundation; either version 2.1 of the License, or
19
(at your option) any later version.
20
21
MySQL++ is distributed in the hope that it will be useful, but WITHOUT
22
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24
License for more details.
25
26
You should have received a copy of the GNU Lesser General Public
27
License along with MySQL++; if not, write to the Free Software
28
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
29
USA
30
***********************************************************************/
31
32
#if !defined(MYSQLPP_COMMON_H)
33
#define MYSQLPP_COMMON_H
34
35
#if !defined(DOXYGEN_IGNORE)
36
// Doxygen will not generate documentation for the following stuff.
37
38
// Enable SSQLS by default. Turned off below on platforms where we
39
// know it doesn't work.
40
#define MYSQLPP_SSQLS_COMPATIBLE
41
42
// For all platforms but Visual C++ 2003, the following macro is just
43
// an alias for "*this". It needs a more complicated definition on
44
// VC++ 2003 to work around an error in the overloaded operator lookup
45
// logic. For an explanation of the problem, see:
46
// http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
47
#define MYSQLPP_QUERY_THISPTR *this
48
49
// Work out major platform-specific stuff here.
50
#if defined(__WIN32__) || defined(_WIN32)
51
# define MYSQLPP_PLATFORM_WINDOWS
52
// Windows compiler support. Tested with Microsoft Visual C++,
53
// Borland C++ Builder, and MinGW GCC.
54
55
// Don't let windows.h (via Connector/C) #define min/max
56
#define NOMINMAX
57
58
// Stuff for Visual C++ only
59
# if defined(_MSC_VER)
60
# define MYSQLPP_PLATFORM_VISUAL_CPP
61
// MS *still* doesn't ship stdint.h, through VC++ 2008 at least.
62
// This means we have to take a wild guess at appropriate
63
// integer types in lib/sql_types.h. See test/inttypes.cpp for
64
// tests that check whether we've guessed well.
65
# define MYSQLPP_NO_STDINT_H
66
# if _MSC_VER < 1400
67
// Workarounds for limitations of VC++ 2003 that are fixed
68
// in 2005 and later.
69
# undef MYSQLPP_QUERY_THISPTR
70
# define MYSQLPP_QUERY_THISPTR dynamic_cast<std::ostream&>(*this)
71
# undef MYSQLPP_SSQLS_COMPATIBLE
72
# elif !defined(_STLP_VERSION) && !defined(_STLP_VERSION_STR)
73
// VC++ 2005 or newer and not using STLport, so #define
74
// portability flags indicating features we can use from
75
// the compiler's native RTL.
76
# define MYSQLPP_HAVE_LOCALTIME_S
77
# define MYSQLPP_HAVE_STD__NOINIT
78
# endif
79
80
// Disable complaints about STL data members: VC++ believes
81
// these need to be __declspec(dllexport) for some reason.
82
# pragma warning(disable: 4251)
83
// Disable complaint that VC++ doesn't grok throw specs
84
# pragma warning(disable: 4290)
85
// Disable whining about using 'this' as a member initializer on VC++.
86
# pragma warning(disable: 4355)
87
// Disable whining about implicit conversions to bool
88
# pragma warning(disable: 4800)
89
// Disable nagging about new "secure" functions like strncpy_s()
90
# pragma warning(disable: 4996)
91
// Call _snprintf() for VC++ version of snprintf() function
92
# define snprintf _snprintf
93
# endif
94
95
// Define DLL import/export tags for Windows compilers, where we build
96
// the library into a DLL, for LGPL license compatibility reasons.
97
// (This is based on a similar mechanism in wxWindows.)
98
99
#ifdef MYSQLPP_MAKING_DLL
100
// When making the DLL, export tagged symbols, so they appear
101
// in the import library.
102
#define MYSQLPP_EXPORT __declspec(dllexport)
103
#elif !defined(MYSQLPP_NO_DLL)
104
// We must be _using_ the DLL, so import symbols instead.
105
#define MYSQLPP_EXPORT __declspec(dllimport)
106
#else
107
// Not making a DLL at all, so no-op these declspecs
108
#define MYSQLPP_EXPORT
109
#endif
110
111
// We need to use the DOS/Windows path separator here
112
#define MYSQLPP_PATH_SEPARATOR '\\'
113
#else
114
// If not VC++, MinGW, or Xcode, we assume we're on a system using
115
// autoconf, so bring in the config.h file it wrote containing the
116
// config test results. Only do this during the library build, and
117
// even then, not if included from a MySQL++ header file, since
118
// config.h cannot be safely installed with the other headers.
119
# if defined(MYSQLPP_NOT_HEADER) && !defined(MYSQLPP_XCODE)
120
# include "config.h"
121
# endif
122
123
// Make DLL stuff a no-op on this platform.
124
#define MYSQLPP_EXPORT
125
126
// Assume POSIX path separator
127
#define MYSQLPP_PATH_SEPARATOR '/'
128
#endif
129
130
#if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
131
# include <mysql/mysql_version.h>
132
#else
133
# include <mysql_version.h>
134
#endif
135
136
namespace
mysqlpp {
137
140
const
bool
use_exceptions =
true
;
141
143
enum
sql_cmp_type { sql_use_compare };
144
145
#if !defined(DOXYGEN_IGNORE)
146
// Figure out how to get large integer support on this system. Suppress
147
// refman documentation for these typedefs, as they're system-dependent.
148
#if defined(MYSQLPP_NO_LONG_LONGS)
149
// Alias "longlong" and "ulonglong" to the regular "long" counterparts
150
typedef
unsigned
long
ulonglong;
151
typedef
long
longlong;
152
#elif defined(_MSC_VER)
153
// It's VC++, so we'll use Microsoft's 64-bit integer types
154
typedef
unsigned
__int64 ulonglong;
155
typedef
__int64 longlong;
156
#else
157
// No better idea, so assume the C99 convention. If your compiler
158
// doesn't support this, please provide a patch to extend this ifdef, or
159
// define MYSQLPP_NO_LONG_LONGS.
160
typedef
unsigned
long
long
ulonglong;
161
typedef
long
long
longlong;
162
#endif
163
#endif // !defined(DOXYGEN_IGNORE)
164
165
#if !defined(MYSQLPP_NO_UNSIGNED_INT_TYPES)
166
typedef
unsigned
long
ulong;
172
#endif
173
174
}
// end namespace mysqlpp
175
176
// The MySQL headers define these macros, which is completely wrong in a
177
// C++ project. Undo the damage.
178
#undef min
179
#undef max
180
181
#endif // !defined(DOXYGEN_IGNORE)
182
183
184
// Now that we've defined all the stuff above, we can pull in the full
185
// MySQL header. Basically, the above largely replaces MySQL's my_global.h
186
// while actually working with C++. This is why we disobey the MySQL
187
// developer docs, which recommend including my_global.h before mysql.h.
188
#if defined(MYSQLPP_MYSQL_HEADERS_BURIED)
189
# include <mysql/mysql.h>
190
#else
191
# include <mysql.h>
192
#endif
193
194
#endif // !defined(MYSQLPP_COMMON_H)
Generated on Wed Mar 18 2015 18:55:03 for MySQL++ by
1.8.5