types.h

Go to the documentation of this file.
00001 
00014 #ifndef _DLR_COMMON_TYPES_H_
00015 #define _DLR_COMMON_TYPES_H_
00016 
00017 namespace dlr {
00018 
00019   namespace common {
00020 
00022     namespace privateCode {
00023 
00024       // This struct template must be specialized once for each
00025       // architecture under which we need to build in order to define
00026       // the sizes of numeric types.  Except for these
00027       // specializations, GlobalTypeStruct is never used directly.
00028       template<int TMPL_SIZEOF_CHAR,
00029                int TMPL_SIZEOF_SHORT_INT,
00030                int TMPL_SIZEOF_INT,
00031                int TMPL_SIZEOF_LONG_INT,
00032                int TMPL_SIZEOF_LONG_LONG_INT,
00033                int TMPL_SIZEOF_FLOAT,
00034                int TMPL_SIZEOF_DOUBLE>
00035       struct GlobalTypeStruct {};
00036 
00037       
00038       // This template specialization defines type names for 32 bit
00039       // i386 machines.
00040       template<>
00041       struct GlobalTypeStruct<1, 2, 4, 4, 8, 4, 8> {
00042         typedef char                    Int8;
00043         typedef short int               Int16;
00044         typedef int                     Int32;
00045         typedef long long int           Int64;
00046         typedef float                   Float32;
00047         typedef double                  Float64;
00048         typedef unsigned char           UnsignedInt8;
00049         typedef unsigned short int      UnsignedInt16;
00050         typedef unsigned int            UnsignedInt32;
00051         typedef unsigned long long int  UnsignedInt64;
00052       };
00053 
00054 
00055       // This template specialization defines type names for x86_64
00056       // machines, such as AMD64 and 64-bit Intel Xeon.
00057       template<>
00058       struct GlobalTypeStruct<1, 2, 4, 8, 8, 4, 8> {
00059         typedef char                    Int8;
00060         typedef short int               Int16;
00061         typedef int                     Int32;
00062         typedef long int                Int64;
00063         typedef float                   Float32;
00064         typedef double                  Float64;
00065         typedef unsigned char           UnsignedInt8;
00066         typedef unsigned short int      UnsignedInt16;
00067         typedef unsigned int            UnsignedInt32;
00068         typedef unsigned long int       UnsignedInt64;
00069       };
00070 
00071 
00072       // This typedef just makes it easier to write the whole slew of
00073       // upcoming typedefs.
00074       typedef
00075       GlobalTypeStruct<sizeof(char),
00076                        sizeof(short int),
00077                        sizeof(int),
00078                        sizeof(long int),
00079                        sizeof(long long int),
00080                        sizeof(float),
00081                        sizeof(double)>
00082       LocalTypeStruct;
00083       
00084     } // namespace privateCode
00086 
00087 
00088     // These are the typedefs we'll actually use in the rest of our
00089     // code.
00090     typedef privateCode::LocalTypeStruct::Int8 Int8;
00091     typedef privateCode::LocalTypeStruct::Int16 Int16;
00092     typedef privateCode::LocalTypeStruct::Int32 Int32;
00093     typedef privateCode::LocalTypeStruct::Int64 Int64;
00094     typedef privateCode::LocalTypeStruct::Float32 Float32;
00095     typedef privateCode::LocalTypeStruct::Float64 Float64;
00096     typedef privateCode::LocalTypeStruct::UnsignedInt8 UnsignedInt8;
00097     typedef privateCode::LocalTypeStruct::UnsignedInt16 UnsignedInt16;
00098     typedef privateCode::LocalTypeStruct::UnsignedInt32 UnsignedInt32;
00099     typedef privateCode::LocalTypeStruct::UnsignedInt64 UnsignedInt64;
00100 
00101   } // namespace common
00102     
00103 }  // namespace dlr
00104 
00105 
00106 /* ======= Declarations to maintain compatibility with legacy code. ======= */
00107 
00108 namespace dlr {
00109 
00110   using common::privateCode::GlobalTypeStruct;
00111   using common::privateCode::LocalTypeStruct;
00112   using common::Int8;
00113   using common::Int16;
00114   using common::Int32;
00115   using common::Int64;
00116   using common::Float32;
00117   using common::Float64;
00118   using common::UnsignedInt8;
00119   using common::UnsignedInt16;
00120   using common::UnsignedInt32;
00121   using common::UnsignedInt64;
00122 
00123 } // namespace dlr
00124   
00125 #endif // #ifndef _DLR_COMMON_TYPES_H_

Generated on Mon Jul 9 20:34:03 2007 for dlrLibs Utility Libraries by  doxygen 1.5.2