library of assembled shared sources

http://lass.cocamware.com

basic_types.h

Go to the documentation of this file.
00001 /** @file
00002  *  @author Bram de Greve (bramz@users.sourceforge.net)
00003  *  @author Tom De Muer (tomdemuer@users.sourceforge.net)
00004  *
00005  *  *** BEGIN LICENSE INFORMATION ***
00006  *  
00007  *  The contents of this file are subject to the Common Public Attribution License 
00008  *  Version 1.0 (the "License"); you may not use this file except in compliance with 
00009  *  the License. You may obtain a copy of the License at 
00010  *  http://lass.sourceforge.net/cpal-license. The License is based on the 
00011  *  Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover 
00012  *  use of software over a computer network and provide for limited attribution for 
00013  *  the Original Developer. In addition, Exhibit A has been modified to be consistent 
00014  *  with Exhibit B.
00015  *  
00016  *  Software distributed under the License is distributed on an "AS IS" basis, WITHOUT 
00017  *  WARRANTY OF ANY KIND, either express or implied. See the License for the specific 
00018  *  language governing rights and limitations under the License.
00019  *  
00020  *  The Original Code is LASS - Library of Assembled Shared Sources.
00021  *  
00022  *  The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
00023  *  The Original Developer is the Initial Developer.
00024  *  
00025  *  All portions of the code written by the Initial Developer are:
00026  *  Copyright (C) 2004-2007 the Initial Developer.
00027  *  All Rights Reserved.
00028  *  
00029  *  Contributor(s):
00030  *
00031  *  Alternatively, the contents of this file may be used under the terms of the 
00032  *  GNU General Public License Version 2 or later (the GPL), in which case the 
00033  *  provisions of GPL are applicable instead of those above.  If you wish to allow use
00034  *  of your version of this file only under the terms of the GPL and not to allow 
00035  *  others to use your version of this file under the CPAL, indicate your decision by 
00036  *  deleting the provisions above and replace them with the notice and other 
00037  *  provisions required by the GPL License. If you do not delete the provisions above,
00038  *  a recipient may use your version of this file under either the CPAL or the GPL.
00039  *  
00040  *  *** END LICENSE INFORMATION ***
00041  */
00042 
00043 /** @defgroup BasicTypes
00044  */
00045 
00046 #ifndef LASS_GUARDIAN_OF_INCLUSION_NUM_BASIC_TYPES_H
00047 #define LASS_GUARDIAN_OF_INCLUSION_NUM_BASIC_TYPES_H
00048 
00049 //#include "num_common.h"
00050 #include "../meta/meta_assert.h"
00051 
00052 #if defined(LASS_NUM_BASIC_TYPES_HAVE_STDINT_H)
00053 #   include <stdint.h>
00054 #endif
00055 
00056 namespace lass
00057 {
00058 namespace num
00059 {
00060 
00061 #if defined(LASS_NUM_BASIC_TYPES_HAVE_STDINT_H)
00062 
00063     typedef int8_t Tint8;   /**< @ingroup BasicTypes */
00064     typedef uint8_t Tuint8; /**< @ingroup BasicTypes */
00065     typedef int16_t Tint16; /**< @ingroup BasicTypes */
00066     typedef uint16_t Tuint16;   /**< @ingroup BasicTypes */
00067     typedef int32_t Tint32; /**< @ingroup BasicTypes */
00068     typedef uint32_t Tuint32;   /**< @ingroup BasicTypes */
00069     typedef int64_t Tint64; /**< @ingroup BasicTypes */
00070     typedef uint64_t Tuint64;   /**< @ingroup BasicTypes */
00071 
00072 #elif defined(LASS_NUM_BASIC_TYPES_HAVE_MSVC)
00073 
00074     typedef signed __int8 Tint8;    /**< @ingroup BasicTypes */
00075     typedef unsigned __int8 Tuint8; /**< @ingroup BasicTypes */
00076     typedef signed __int16 Tint16;  /**< @ingroup BasicTypes */
00077     typedef unsigned __int16 Tuint16;   /**< @ingroup BasicTypes */
00078     typedef signed __int32 Tint32;  /**< @ingroup BasicTypes */
00079     typedef unsigned __int32 Tuint32;   /**< @ingroup BasicTypes */
00080     typedef signed __int64 Tint64;  /**< @ingroup BasicTypes */
00081     typedef unsigned __int64 Tuint64;   /**< @ingroup BasicTypes */
00082 
00083 #else
00084 
00085     typedef signed char Tint8;  /**< @ingroup BasicTypes */
00086     typedef unsigned char Tuint8;   /**< @ingroup BasicTypes */
00087     typedef signed short Tint16;    /**< @ingroup BasicTypes */
00088     typedef unsigned short Tuint16; /**< @ingroup BasicTypes */
00089     typedef signed int Tint32;  /**< @ingroup BasicTypes */
00090     typedef unsigned int Tuint32;   /**< @ingroup BasicTypes */
00091     typedef signed long long Tint64;    /**< @ingroup BasicTypes */
00092     typedef unsigned long long Tuint64; /**< @ingroup BasicTypes */
00093 
00094 #endif
00095 
00096 
00097 
00098 typedef float Tfloat32; /**< @ingroup BasicTypes */
00099 typedef double Tfloat64;    /**< @ingroup BasicTypes */
00100 
00101 
00102 /** @ingroup BasicTypes
00103  */
00104 template <size_t iNumberOfBits> struct BasicType {};
00105 template <> struct BasicType< 8> { typedef Tint8  Tint; typedef Tuint8  Tuint; };
00106 template <> struct BasicType<16> { typedef Tint16 Tint; typedef Tuint16 Tuint; };
00107 template <> struct BasicType<32> { typedef Tint32 Tint; typedef Tuint32 Tuint; typedef Tfloat32 Tfloat; };
00108 template <> struct BasicType<64> { typedef Tint64 Tint; typedef Tuint64 Tuint; typedef Tfloat64 Tfloat; };
00109 
00110 
00111 
00112 typedef BasicType<sizeof(void*) * lass::bitsPerByte>::Tint TintPtr; /**< @ingroup BasicTypes */
00113 typedef BasicType<sizeof(void*) * lass::bitsPerByte>::Tuint TuintPtr;   /**< @ingroup BasicTypes */
00114 
00115 /** @ingroup BasicTypes
00116  */
00117 template <typename T> struct DoublePrecision { };
00118 template <> struct DoublePrecision<float> { typedef double Type; };
00119 template <> struct DoublePrecision<double> { typedef long double Type; };
00120 template <> struct DoublePrecision<long double> { typedef long double Type; };
00121 
00122 
00123 
00124 // --- meta assertions -----------------------------------------------------------------------------
00125 
00126 namespace impl
00127 {
00128 
00129 LASS_META_ASSERT(lass::bitsPerByte == 8, one_byte_is_not_8_bits);
00130 LASS_META_ASSERT(sizeof(lass::num::Tint8) * lass::bitsPerByte == 8, Tint8_must_be_8_bits_);
00131 LASS_META_ASSERT(sizeof(lass::num::Tuint8) * lass::bitsPerByte == 8, Tuint8_must_be_8_bits);
00132 LASS_META_ASSERT(sizeof(lass::num::Tint16) * lass::bitsPerByte == 16, Tint16_must_be_16_bits);
00133 LASS_META_ASSERT(sizeof(lass::num::Tuint16) * lass::bitsPerByte == 16, Tuint16_must_be_16_bits);
00134 LASS_META_ASSERT(sizeof(lass::num::Tint32) * lass::bitsPerByte == 32, Tint32_must_be_32_bits);
00135 LASS_META_ASSERT(sizeof(lass::num::Tuint32) * lass::bitsPerByte == 32, Tuint32_must_be_32_bits);
00136 LASS_META_ASSERT(sizeof(lass::num::Tint64) * lass::bitsPerByte == 64, Tint64_must_be_64_bits);
00137 LASS_META_ASSERT(sizeof(lass::num::Tuint64) * lass::bitsPerByte == 64, Tuint64_must_be_64_bits);
00138 LASS_META_ASSERT(sizeof(lass::num::Tfloat32) * lass::bitsPerByte == 32, Tfloat32_must_be_32_bits);
00139 LASS_META_ASSERT(sizeof(lass::num::Tfloat64) * lass::bitsPerByte == 64, Tfloat64_must_be_64_bits);
00140 LASS_META_ASSERT(sizeof(lass::num::TintPtr) == sizeof(void*), TintPtr_must_be_size_of_pointer);
00141 LASS_META_ASSERT(sizeof(lass::num::TuintPtr) == sizeof(void*), TuintPtr_must_be_size_of_pointer);
00142 
00143 }
00144 
00145 }
00146 
00147 }
00148 
00149 #endif

Generated on Mon Nov 10 14:20:00 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo