# sql_types.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008 /***********************************************************************
    00009  Copyright (c) 2006-2008 by Educational Technology Resources, Inc.
    00010  Others may also hold copyrights on code in this file.  See the
    00011  CREDITS 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_SQL_TYPES_H_MAIN)
    00032 #define MYSQLPP_SQL_TYPES_H_MAIN
    00033
    00034 #include "common.h"
    00035 #include "tiny_int.h"
    00036
    00037 #include <string>
    00038
    00039 namespace mysqlpp {
    00040
    00041 #if !defined(DOXYGEN_IGNORE)
    00042 // Suppress refman documentation for these typedefs, as they're
    00043 // system-dependent.
    00044
    00045 // Define C++ integer types that are most nearly equivalent to those
    00046 // used by the MySQL server.
    00047 #if defined(MYSQLPP_NO_STDINT_H)
    00048         // Boo, we're going to have to wing it.
    00049         typedef tiny_int<signed char>   sql_tinyint;
    00050         typedef tiny_int<unsigned char> sql_tinyint_unsigned;
    00051         typedef signed short                    sql_smallint;
    00052         typedef unsigned short                  sql_smallint_unsigned;
    00053         typedef signed int                              sql_int;
    00054         typedef unsigned int                    sql_int_unsigned;
    00055         typedef signed int                              sql_mediumint;
    00056         typedef unsigned int                    sql_mediumint_unsigned;
    00057         typedef longlong                                sql_bigint;
    00058         typedef ulonglong                               sql_bigint_unsigned;
    00059 #else
    00060         // Assume a system where C99 is supported in C++ in advance of
    00061         // actual standardization, so we can do this portably.
    00062 #       include <stdint.h>
    00063         typedef tiny_int<int8_t>                sql_tinyint;
    00064         typedef tiny_int<uint8_t>               sql_tinyint_unsigned;
    00065         typedef int16_t                                 sql_smallint;
    00066         typedef uint16_t                                sql_smallint_unsigned;
    00067         typedef int32_t                                 sql_int;
    00068         typedef uint32_t                                sql_int_unsigned;
    00069         typedef int32_t                                 sql_mediumint;
    00070         typedef uint32_t                                sql_mediumint_unsigned;
    00071         typedef int64_t                                 sql_bigint;
    00072         typedef uint64_t                                sql_bigint_unsigned;
    00073 #endif
    00074
    00075 // Now define typedef equivalencies for the other standard MySQL
    00076 // data types.  There aren't serious portability issues here.
    00077 typedef float                                   sql_float;
    00078 typedef double                                  sql_double;
    00079 typedef double                                  sql_decimal;
    00080 typedef std::string                             sql_enum;
    00081 typedef std::string                             sql_char;
    00082 typedef std::string                             sql_varchar;
    00083 typedef std::string                             sql_tinytext;
    00084 typedef std::string                             sql_text;
    00085 typedef std::string                             sql_mediumtext;
    00086 typedef std::string                             sql_longtext;
    00087
    00088 // Aliases to match the rules MySQL uses in translating data types
    00089 // from other database servers into its own type system.  From:
    00090 // http://dev.mysql.com/doc/refman/5.0/en/other-vendor-data-types.html
    00091 typedef sql_tinyint                             sql_bool;
    00092 typedef sql_tinyint                             sql_boolean;
    00093 typedef sql_varchar                             sql_character_varying;
    00094 typedef sql_decimal                             sql_fixed;
    00095 typedef sql_float                               sql_float4;
    00096 typedef sql_double                              sql_float8;
    00097 typedef sql_tinyint                             sql_int1;
    00098 typedef sql_smallint                    sql_int2;
    00099 typedef sql_mediumint                   sql_int3;
    00100 typedef sql_int                                 sql_int4;
    00101 typedef sql_bigint                              sql_int8;
    00102 typedef sql_mediumtext                  sql_long_varchar;
    00103 typedef sql_mediumtext                  sql_long;
    00104 typedef sql_mediumint                   sql_middleint;
    00105 typedef sql_decimal                             sql_numeric;
    00106 #endif // !defined(DOXYGEN_IGNORE)
    00107
    00108 } // end namespace mysqlpp
    00109
    00110 #endif // !defined(MYSQLPP_SQL_TYPES_H_MAIN)
    00111
    00112
    00113 // The following sections are treated separately to avoid making the
    00114 // #include tree too dense: if mystring.h (for example) is not yet
    00115 // #included, no sense pulling it in to define all the typedefs based
    00116 // on String.  The separate #include guards for each section allow
    00117 // this file to be #included as many times as necessary to build up the
    00118 // full typedef set.  This trickery is necessary because sql_types.h
    00119 // is needed in a few places within MySQL++, but we can't (and don't)
    00120 // depend on having the full set of typedefs.  mysql++.h #includes this
    00121 // at a late stage, ensuring that end-user code does see the full set.
    00122 #if defined(MYSQLPP_MYSTRING_H) && !defined(MYSQLPP_SQL_TYPES_H_MYSTRING) && !defined(DOXYGEN_IGNORE)
    00123 #       define MYSQLPP_SQL_TYPES_H_MYSTRING
    00124         namespace mysqlpp {
    00125                 typedef String                  sql_blob;
    00126                 typedef String                  sql_tinyblob;
    00127                 typedef String                  sql_mediumblob;
    00128                 typedef String                  sql_longblob;
    00129                 typedef sql_mediumblob  sql_long_varbinary;
    00130         } // end namespace mysqlpp
    00131 #endif
    00132
    00133
    00134 #if defined(MYSQLPP_DATETIME_H) && !defined(MYSQLPP_SQL_TYPES_H_DATETIME) && !defined(DOXYGEN_IGNORE)
    00135 #       define MYSQLPP_SQL_TYPES_H_DATETIME
    00136         namespace mysqlpp {
    00137                 typedef Date                    sql_date;
    00138                 typedef Time                    sql_time;
    00139                 typedef DateTime                sql_timestamp;
    00140                 typedef DateTime                sql_datetime;
    00141         } // end namespace mysqlpp
    00142 #endif
    00143
    00144
    00145 #if defined(MYSQLPP_MYSET_H) && !defined(MYSQLPP_SQL_TYPES_H_SET) && !defined(DOXYGEN_IGNORE)
    00146 #       define MYSQLPP_SQL_TYPES_H_SET
    00147         namespace mysqlpp {
    00148                 typedef Set<>                           sql_set;
    00149         } // end namespace mysqlpp
    00150 #endif
    00151