00001 // DataTypeCode.h 00002 ////////////////////////////////////////////////////////////////////// 00003 // (c) Copyright 2002 Brown Deer Technology, LLC. 00004 // All rights reserved. 00005 ////////////////////////////////////////////////////////////////////// 00006 00007 #ifndef DATATYPECODE_H 00008 #define DATATYPECODE_H 00009 00010 #define DATATYPECODE_UNKNOWN 0x00 00011 #define DATATYPECODE_BOOL 0x01 00012 #define DATATYPECODE_CHAR 0x02 00013 #define DATATYPECODE_INT 0x03 00014 #define DATATYPECODE_FLOAT 0x04 00015 #define DATATYPECODE_DOUBLE 0x05 00016 00017 #ifndef UNKNOWN_ 00018 #define UNKNOWN_ 00019 class unknown{}; 00020 #endif 00021 00022 template< class Type = unknown > 00023 class DataTypeCode_type{ 00024 public: static const int code() { return DATATYPECODE_UNKNOWN; } 00025 }; 00026 00027 template<> 00028 class DataTypeCode_type<bool>{ 00029 public: static const int code() { return DATATYPECODE_BOOL; } 00030 }; 00031 00032 template<> 00033 class DataTypeCode_type<char>{ 00034 public: static const int code() { return DATATYPECODE_CHAR; } 00035 }; 00036 00037 template<> 00038 class DataTypeCode_type<int>{ 00039 public: static const int code() { return DATATYPECODE_INT; } 00040 }; 00041 00042 template<> 00043 class DataTypeCode_type<float>{ 00044 public: static const int code() { return DATATYPECODE_FLOAT; } 00045 }; 00046 00047 template<> 00048 class DataTypeCode_type<double>{ 00049 public: static const int code() { return DATATYPECODE_DOUBLE; } 00050 }; 00051 00052 template< int Code = DATATYPECODE_UNKNOWN > 00053 class DataTypeCode_code{ public: typedef unknown type; }; 00054 00055 template<> 00056 class DataTypeCode_code<DATATYPECODE_BOOL>{ public: typedef bool type; }; 00057 00058 template<> 00059 class DataTypeCode_code<DATATYPECODE_CHAR>{ public: typedef char type; }; 00060 00061 template<> 00062 class DataTypeCode_code<DATATYPECODE_INT>{ public: typedef int type; }; 00063 00064 template<> 00065 class DataTypeCode_code<DATATYPECODE_FLOAT>{ public: typedef float type; }; 00066 00067 template<> 00068 class DataTypeCode_code<DATATYPECODE_DOUBLE>{ public: typedef double type; }; 00069 00070 #endif 00071
1.3.6