MySQL++ Reference Manual

Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members

# convert.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, 2005 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 #ifndef MYSQLPP_CONVERT_H
    00032 #define MYSQLPP_CONVERT_H
    00033
    00034 #include "platform.h"
    00035
    00036 #include "defs.h"
    00037
    00038 #include <stdlib.h>
    00039
    00040 namespace mysqlpp {
    00041
    00042 #if !defined(DOXYGEN_IGNORE)
    00043 // Doxygen will not generate documentation for this section.
    00044
    00045 template <class Type> class mysql_convert;
    00046
    00047 #define mysql__convert(TYPE, FUNC) \
    00048   template <> \
    00049   class mysql_convert<TYPE> {\
    00050   public:\
    00051     mysql_convert(const char* str, const char *& end) { \
    00052       num_ = FUNC(str, const_cast<char **>(&end));}\
    00053     operator TYPE () {return num_;}\
    00054   private:\
    00055     TYPE num_;\
    00056   };\
    00057
    00058 #if defined(_MSC_VER)
    00059 #       pragma warning(disable: 4244)
    00060 #endif
    00061
    00062         mysql__convert(float, strtod)
    00063         mysql__convert(double, strtod)
    00064
    00065 #if defined(_MSC_VER)
    00066 #       pragma warning(default: 4244)
    00067 #endif
    00068
    00069 #undef mysql__convert
    00070 #define mysql__convert(TYPE, FUNC) \
    00071   template <> \
    00072   class mysql_convert<TYPE> {\
    00073   public:\
    00074     mysql_convert(const char* str, const char *& end) { \
    00075       num_ = FUNC(str, const_cast<char **>(&end),10);}\
    00076     operator TYPE () {return num_;}\
    00077   private:\
    00078     TYPE num_;\
    00079   };\
    00080
    00081 #if defined(_MSC_VER)
    00082 #       pragma warning(disable: 4244)
    00083 #endif
    00084
    00085         mysql__convert(char, strtol)
    00086         mysql__convert(signed char, strtol)
    00087         mysql__convert(int, strtol)
    00088         mysql__convert(short int, strtol)
    00089         mysql__convert(long int, strtol)
    00090
    00091         mysql__convert(unsigned char, strtoul)
    00092         mysql__convert(unsigned int, strtoul)
    00093         mysql__convert(unsigned short int, strtoul)
    00094         mysql__convert(unsigned long int, strtoul)
    00095
    00096 #if defined(_MSC_VER)
    00097 #       pragma warning(default: 4244)
    00098 #endif
    00099
    00100 #if !defined(NO_LONG_LONGS)
    00101 #if defined(__GNUC__)
    00102 mysql__convert(longlong, strtoll)
    00103 mysql__convert(ulonglong, strtoull)
    00104 #elif defined(_MSC_VER)
    00105 mysql__convert(longlong, _strtoi64)
    00106 mysql__convert(ulonglong, _strtoui64)
    00107 #else
    00108 #error Fix me! I need the "string to 64-bit int" function for your platform!
    00109 #endif
    00110 #endif // !defined(NO_LONG_LONGS)
    00111
    00112 #endif // !defined(DOXYGEN_IGNORE)
    00113
    00114 } // end namespace mysqlpp
    00115
    00116 #endif
    00117