MySQL++ Reference Manual

- Main Page
- Classes
- Files

- File List
- File Members

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