include/corelib/ncbi_limits.h

Go to the documentation of this file.
00001 #ifndef CORELIB___NCBI_LIMITS__H
00002 #define CORELIB___NCBI_LIMITS__H
00003 
00004 /*  $Id: ncbi_limits.h 164289 2009-06-24 21:18:16Z vakatov $
00005  * ===========================================================================
00006  *
00007  *                            PUBLIC DOMAIN NOTICE
00008  *               National Center for Biotechnology Information
00009  *
00010  *  This software/database is a "United States Government Work" under the
00011  *  terms of the United States Copyright Act.  It was written as part of
00012  *  the author's official duties as a United States Government employee and
00013  *  thus cannot be copyrighted.  This software/database is freely available
00014  *  to the public for use. The National Library of Medicine and the U.S.
00015  *  Government have not placed any restriction on its use or reproduction.
00016  *
00017  *  Although all reasonable efforts have been taken to ensure the accuracy
00018  *  and reliability of the software and data, the NLM and the U.S.
00019  *  Government do not and cannot warrant the performance or results that
00020  *  may be obtained by using this software or data. The NLM and the U.S.
00021  *  Government disclaim all warranties, express or implied, including
00022  *  warranties of performance, merchantability or fitness for any particular
00023  *  purpose.
00024  *
00025  *  Please cite the author in any work or product based on this material.
00026  *
00027  * ===========================================================================
00028  *
00029  * Author:  Denis Vakatov
00030  *
00031  *
00032  */
00033 
00034 /**
00035  * @file ncbitype.h
00036  *
00037  * Defines Limits for the types used in NCBI C/C++ toolkit.
00038  *
00039  *   Limits for the NCBI C/C++ fixed-size types:
00040  *      Char, Uchar
00041  *      Int1, Uint1  --  kMin_I1,       kMax_I1,       kMax_UI1
00042  *      Int2, Uint2  --  kMin_I2,       kMax_I2,       kMax_UI2
00043  *      Int4, Uint4  --  kMin_I4,       kMax_I4,       kMax_UI4
00044  *      Int8, Uint8  --  kMin_I8,       kMax_I8,       kMax_UI8
00045  *
00046  *   Limits for the built-in integer types:
00047  *      "char"       --  kMin_Char,     kMax_Char,     kMax_UChar
00048  *      "short"      --  kMin_Short,    kMax_Short,    kMax_UShort
00049  *      "int"        --  kMin_Int,      kMax_Int,      kMax_UInt
00050  *      "long"       --  kMin_Long,     kMax_Long,     kMax_ULong
00051  *      "long long"  --  kMin_LongLong, kMax_LongLong, kMax_ULongLong
00052  *      "__int64"    --  kMin_Int64,    kMax_Int64,    kMax_UInt64
00053  *
00054  *   Limits for the built-in floating-point types:
00055  *      "float"      --  kMin_Float,    kMax_Float
00056  *      "double"     --  kMin_Double,   kMax_Double
00057  *
00058  */
00059 
00060 #include <corelib/ncbitype.h>
00061 #include <limits.h>
00062 #include <float.h>
00063 #ifdef HAVE_WCHAR_H
00064 #include <wchar.h>
00065 #endif
00066 
00067 
00068 /** @addtogroup Portability
00069  *
00070  * @{
00071  */
00072 
00073 
00074 /* Int8, Uint8
00075  *   NOTE:  "NCBI_MIN/MAX_***8" are temporary preprocessor definitions, so
00076  *          do not use them... always use "kMax_*" and "kMin_*" instead!
00077  */
00078 #if   (SIZEOF_LONG == 8)
00079 #  define NCBI_MIN_I8  LONG_MIN
00080 #  define NCBI_MAX_I8  LONG_MAX
00081 #  define NCBI_MAX_UI8 ULONG_MAX
00082 #elif (SIZEOF_LONG_LONG == 8)
00083 #  define NCBI_MIN_I8  0x8000000000000000LL
00084 #  define NCBI_MAX_I8  0x7FFFFFFFFFFFFFFFLL
00085 #  define NCBI_MAX_UI8 0xFFFFFFFFFFFFFFFFULL
00086 #elif defined(NCBI_INT8_IS_INT64)
00087 #  define NCBI_MIN_I8  0x8000000000000000i64
00088 #  define NCBI_MAX_I8  0x7FFFFFFFFFFFFFFFi64
00089 #  define NCBI_MAX_UI8 0xFFFFFFFFFFFFFFFFui64
00090 #endif
00091 
00092 
00093 /*  Limits:  C++ and C interfaces
00094  */
00095 
00096 #ifdef __cplusplus
00097 /* (BEGIN C++ interface) */
00098 
00099 /* [C++]  built-in integer types */
00100 const signed   char   kMin_Char   = CHAR_MIN;
00101 const signed   char   kMax_Char   = CHAR_MAX;
00102 const signed   char   kMin_SChar  = SCHAR_MIN;
00103 const signed   char   kMax_SChar  = SCHAR_MAX;
00104 const unsigned char   kMax_UChar  = UCHAR_MAX;
00105 
00106 #if defined(HAVE_WCHAR_H)  &&  defined(WCHAR_MIN)
00107 const wchar_t kMin_WChar = WCHAR_MIN;
00108 const wchar_t kMax_WChar = WCHAR_MAX;
00109 #endif
00110 
00111 const signed   short  kMin_Short  = SHRT_MIN;
00112 const signed   short  kMax_Short  = SHRT_MAX;
00113 const unsigned short  kMax_UShort = USHRT_MAX;
00114 
00115 const signed   int    kMin_Int    = INT_MIN;
00116 const signed   int    kMax_Int    = INT_MAX;
00117 const unsigned int    kMax_UInt   = UINT_MAX;
00118 
00119 const signed   long   kMin_Long   = LONG_MIN;
00120 const signed   long   kMax_Long   = LONG_MAX;
00121 const unsigned long   kMax_ULong  = ULONG_MAX;
00122 
00123 #  if (SIZEOF_LONG_LONG == 8)
00124 const signed   long long  kMin_LongLong   = 0x8000000000000000LL;
00125 const signed   long long  kMax_LongLong   = 0x7FFFFFFFFFFFFFFFLL;
00126 const unsigned long long  kMax_ULongLong  = 0xFFFFFFFFFFFFFFFFULL;
00127 #  elif (SIZEOF_LONG_LONG == 4)
00128 const signed   long long  kMin_LongLong   = 0x80000000LL;
00129 const signed   long long  kMax_LongLong   = 0x7FFFFFFFLL;
00130 const unsigned long long  kMax_ULongLong  = 0xFFFFFFFFULL;
00131 #  endif
00132 
00133 #  if defined(NCBI_INT8_IS_INT64)
00134 const signed   __int64 kMin_Int64  = NCBI_MIN_I8;
00135 const signed   __int64 kMax_Int64  = NCBI_MAX_I8;
00136 const unsigned __int64 kMax_UInt64 = NCBI_MAX_UI8;
00137 #  endif
00138 
00139 /* [C++]  built-in floating-point types */
00140 const float kMin_Float = FLT_MIN;
00141 const float kMax_Float = FLT_MAX;
00142 
00143 const double kMin_Double = DBL_MIN;
00144 const double kMax_Double = DBL_MAX;
00145 
00146 /* [C++]  NCBI fixed-size types */
00147 const Int1  kMin_I1  = SCHAR_MIN;
00148 const Int1  kMax_I1  = SCHAR_MAX;
00149 const Uint1 kMax_UI1 = UCHAR_MAX;
00150 
00151 const Int2  kMin_I2  = SHRT_MIN;
00152 const Int2  kMax_I2  = SHRT_MAX;
00153 const Uint2 kMax_UI2 = USHRT_MAX;
00154 
00155 const Int4  kMin_I4  = INT_MIN;
00156 const Int4  kMax_I4  = INT_MAX;
00157 const Uint4 kMax_UI4 = UINT_MAX;
00158 
00159 const Int8  kMin_I8  = NCBI_MIN_I8;
00160 const Int8  kMax_I8  = NCBI_MAX_I8;
00161 const Uint8 kMax_UI8 = NCBI_MAX_UI8;
00162 #  undef NCBI_MIN_I8
00163 #  undef NCBI_MAX_I8
00164 #  undef NCBI_MAX_UI8
00165 
00166 
00167 /* (END of C++ interface) */
00168 #else
00169 /* (BEGIN C interface) */
00170 
00171 
00172 /* [ C ]  built-in integer types */
00173 #  define kMin_Char   CHAR_MIN
00174 #  define kMax_Char   CHAR_MAX
00175 #  define kMin_SChar  SCHAR_MIN
00176 #  define kMax_SChar  SCHAR_MAX
00177 #  define kMax_UChar  UCHAR_MAX
00178 
00179 #  define kMin_Short  SHRT_MIN
00180 #  define kMax_Short  SHRT_MAX
00181 #  define kMax_UShort USHRT_MAX
00182 
00183 #  define kMin_Int    INT_MIN
00184 #  define kMax_Int    INT_MAX
00185 #  define kMax_UInt   UINT_MAX
00186 
00187 #  if (SIZEOF_LONG_LONG == 8)
00188 #    define kMin_LongLong   0x8000000000000000LL
00189 #    define kMax_LongLong   0x7FFFFFFFFFFFFFFFLL
00190 #    define kMax_ULongLong  0xFFFFFFFFFFFFFFFFULL
00191 #  elif (SIZEOF_LONG_LONG == 4)
00192 #    define kMin_LongLong   0x80000000LL
00193 #    define kMax_LongLong   0x7FFFFFFFLL
00194 #    define kMax_ULongLong  0xFFFFFFFFULL
00195 #  endif
00196 
00197 #  if (SIZEOF___INT64 == 8)
00198 #    define __int64 kMin_Int64  0x8000000000000000i64
00199 #    define __int64 kMax_Int64  0x7FFFFFFFFFFFFFFFi64
00200 #    define __int64 kMax_UInt64 0xFFFFFFFFFFFFFFFFui64
00201 #  endif
00202 
00203 /* [ C ]  built-in floating-point types */
00204 #  define kMin_Float  FLT_MIN;
00205 #  define kMax_Float  FLT_MAX;
00206 
00207 #  define kMin_Double DBL_MIN;
00208 #  define kMax_Double DBL_MAX;
00209 
00210 /* [ C ]  NCBI fixed-size types */
00211 #  define kMin_I1   SCHAR_MIN
00212 #  define kMax_I1   SCHAR_MAX
00213 #  define kMax_UI1  UCHAR_MAX
00214 #  define kMin_I2   SHRT_MIN
00215 #  define kMax_I2   SHRT_MAX
00216 #  define kMax_UI2  USHRT_MAX
00217 #  define kMin_I4   INT_MIN
00218 #  define kMax_I4   INT_MAX
00219 #  define kMax_UI4  UINT_MAX
00220 #  define kMin_I8   NCBI_MIN_I8
00221 #  define kMax_I8   NCBI_MAX_I8
00222 #  define kMax_UI8  NCBI_MAX_UI8
00223 
00224 
00225 /* (END of C interface) */
00226 #endif  /* __cplusplus */
00227 
00228 
00229 #endif /* CORELIB___NCBI_LIMITS__H */
00230 
00231 
00232 /* @} */
00233 
00234 

Generated on Wed Dec 9 03:01:44 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:17:29 2009 by modify_doxy.py rev. 173732