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 #ifndef MYSQLPP_CONVERT_H
00002 #define MYSQLPP_CONVERT_H
00003 
00009 
00010 #include "platform.h"
00011 
00012 #include "defs.h"
00013 
00014 #include <stdlib.h>
00015 
00016 namespace mysqlpp {
00017 
00019 // Doxygen will not generate documentation for this section.
00020 
00021 template <class Type> class mysql_convert;
00022 
00023 #define mysql__convert(TYPE, FUNC) \
00024   template <> \
00025   class mysql_convert<TYPE> {\
00026   private:\
00027     TYPE num;\
00028   public:\
00029     mysql_convert(const char* str, const char *& end) { \
00030       num = FUNC(str, const_cast<char **>(&end));}\
00031     operator TYPE () {return num;}\
00032   };\
00033 
00034 #if defined(_MSC_VER)
00035 #       pragma warning(disable: 4244)
00036 #endif
00037 
00038         mysql__convert(float, strtod)
00039         mysql__convert(double, strtod)
00040 
00041 #if defined(_MSC_VER)
00042 #       pragma warning(default: 4244)
00043 #endif
00044 
00045 #undef mysql__convert
00046 #define mysql__convert(TYPE, FUNC) \
00047   template <> \
00048   class mysql_convert<TYPE> {\
00049   private:\
00050     TYPE num;\
00051   public:\
00052     mysql_convert(const char* str, const char *& end) { \
00053       num = FUNC(str, const_cast<char **>(&end),10);}\
00054     operator TYPE () {return num;}\
00055   };\
00056 
00057 #if defined(_MSC_VER)
00058 #       pragma warning(disable: 4244)
00059 #endif
00060 
00061         mysql__convert(char, strtol)
00062         mysql__convert(signed char, strtol)
00063         mysql__convert(int, strtol)
00064         mysql__convert(short int, strtol)
00065         mysql__convert(long int, strtol)
00066 
00067         mysql__convert(unsigned char, strtoul)
00068         mysql__convert(unsigned int, strtoul)
00069         mysql__convert(unsigned short int, strtoul)
00070         mysql__convert(unsigned long int, strtoul)
00071 
00072 #if defined(_MSC_VER)
00073 #       pragma warning(default: 4244)
00074 #endif
00075 
00076 #if !defined(NO_LONG_LONGS)
00077 #if defined(__GNUC__)
00078 mysql__convert(longlong, strtoll)
00079 mysql__convert(ulonglong, strtoull)
00080 #elif defined(_MSC_VER)
00081 mysql__convert(longlong, _strtoi64)
00082 mysql__convert(ulonglong, _strtoui64)
00083 #else
00084 #error Fix me! I need the "string to 64-bit int" function for your platform!
00085 #endif
00086 #endif // !defined(NO_LONG_LONGS)
00087 
00089 
00090 } // end namespace mysqlpp
00091 
00092 #endif
00093 

Generated on Thu May 5 05:30:43 2005 for MySQL++ by doxygen1.2.18