Main Page | Class Hierarchy | Class List | File List | Class Members

stdtp.h

00001 //-< STDTP.H >-------------------------------------------------------*--------*
00002 // GigaBASE                  Version 1.0         (c) 1999  GARRET    *     ?  *
00003 // (Post Relational Database Management System)                      *   /\|  *
00004 //                                                                   *  /  \  *
00005 //                          Created:     20-Nov-98    K.A. Knizhnik  * / [] \ *
00006 //                          Last update: 10-Dec-98    K.A. Knizhnik  * GARRET *
00007 //-------------------------------------------------------------------*--------*
00008 // Standart type and macro definitions
00009 //-------------------------------------------------------------------*--------*
00010 
00011 #ifndef __STDTP_H__
00012 #define __STDTP_H__
00013 
00014 #include "config.h"
00015 
00016 #ifdef GIGABASE_DLL
00017 #ifdef INSIDE_GIGABASE
00018 #define GIGABASE_DLL_ENTRY __declspec(dllexport)
00019 #else
00020 #define GIGABASE_DLL_ENTRY __declspec(dllimport)
00021 #endif
00022 #else
00023 #define GIGABASE_DLL_ENTRY
00024 #endif
00025 
00026 #ifdef USE_NAMESPACES
00027 #define BEGIN_GIGABASE_NAMESPACE namespace gigabase {
00028 #define END_GIGABASE_NAMESPACE }
00029 #define USE_GIGABASE_NAMESPACE using namespace gigabase;
00030 #else
00031 #define BEGIN_GIGABASE_NAMESPACE
00032 #define END_GIGABASE_NAMESPACE
00033 #define USE_GIGABASE_NAMESPACE 
00034 #endif
00035 
00036 #if defined(__MINGW32__) && !defined(_WIN32)
00037 #define _WIN32
00038 #endif
00039 
00040 #if defined(_WIN32_WCE) && !defined(_WINCE)
00041 #define _WINCE
00042 #endif
00043 
00044 
00045 #if defined(USE_MFC_STRING) && !defined(USE_MFC) && !defined(USE_ATL)
00046 #define USE_ATL 1
00047 #endif
00048 
00049 #if defined(USE_MFC_STRING)
00050 #ifndef MFC_STRING
00051 #define MFC_STRING CString
00052 #endif
00053 #endif
00054 
00055 #ifdef USE_STD_STRING
00056 #include <string>
00057 #endif
00058 
00059 #if defined(_WIN32)
00060 
00061 #ifdef USE_MFC
00062 #include <afx.h>
00063 #include <winsock2.h>
00064 #else
00065 #include <windows.h>
00066 #if defined(USE_ATL) && defined(USE_MFC_STRING)
00067 #include <atlstr.h>
00068 #endif
00069 #endif
00070 
00071 #ifdef _MSC_VER
00072 #pragma warning(disable:4800 4355 4146 4251)
00073 #endif
00074 #else
00075 #ifdef _AIX
00076 #define INT8_IS_DEFINED
00077 #endif
00078 #ifndef NO_PTHREADS
00079 #ifndef _REENTRANT
00080 #define _REENTRANT
00081 #endif
00082 #endif
00083 #endif
00084 
00085 
00086 
00087 #if defined(__VACPP_MULTI__) // IBM compiler produce a lot of stupid warnings
00088 #pragma report(disable, "CPPC1608")
00089 #pragma report(disable, "CPPC1281")
00090 #endif /* __VACPP_MULTI__ */
00091 
00092 
00093 #ifdef _WINCE
00094 #include <stdio.h>
00095 #include <stdlib.h>
00096 #include <string.h>
00097 #include <limits.h>
00098 #include <stdarg.h>
00099 #include <tchar.h>
00100 #include "wince.h"
00101 
00102 #else
00103 
00104 #include <stdio.h>
00105 #include <stddef.h>
00106 #include <stdlib.h>
00107 #include <string.h>
00108 #include <limits.h>
00109 #include <assert.h>
00110 #include <stdarg.h>
00111 #include <time.h>
00112 #ifdef UNICODE
00113 #include <wchar.h>
00114 #include <wctype.h>
00115 #else
00116 #include <ctype.h>
00117 #endif
00118 
00119 #endif
00120 
00121 #ifndef __IBMCPP__
00122 BEGIN_GIGABASE_NAMESPACE
00123 #endif
00124 
00125 //#ifndef __BCPLUSPLUS__
00126 #if !defined(_WIN32) && !defined(__cdecl)
00127 #define __cdecl
00128 #endif
00129 
00130 
00131 // Align value 'x' to boundary 'b' which should be power of 2
00132 #define DOALIGN(x,b)   (((x) + (b) - 1) & ~((b) - 1))
00133 
00134 
00135 #ifdef UNICODE
00136 typedef wchar_t char_t;
00137 #define STRLEN(x)     wcslen(x)
00138 #define STRCMP(x, y)  wcscmp(x, y)
00139 #define STRCHR(x, y)  wcschr(x, y)
00140 #define STRCPY(x, y)  wcscpy(x, y)
00141 #define STRNCPY(x,y,z) wcsncpy(x, y, z)
00142 #define STRCOLL(x, y) wcscoll(x, y)
00143 #define STRNCMP(x,y,z) wcsncmp(x, y, z)
00144 #define STRLITERAL(x) (wchar_t*)L##x
00145 #define PRINTF        wprintf
00146 #define FPRINTF       fwprintf
00147 #define SPRINTF       swprintf
00148 #define VSPRINTF      vswprintf
00149 #define FSCANF        fwscanf
00150 #define SSCANF        swscanf
00151 #define GETC(x)       getwc(x)
00152 #define UNGETC(x, y)  ungetwc(x, y)
00153 #define TOLOWER(x)    towlower((x) & 0xFFFF)
00154 #define TOUPPER(x)    towlower((x) & 0xFFFF)
00155 #define ISALNUM(x)    iswalnum((x) & 0xFFFF)
00156 #define STRSTR(x, y)  wcsstr(x, y)
00157 #define STRXFRM(x,y,z) wcsxfrm(x, y, z)
00158 #define STRFTIME(a,b,c,d) wcsftime(a,b,c,d)
00159 #ifdef _WINCE
00160 #define REMOVE_FILE(s) DeleteFile(s)
00161 #define RENAME_FILE(p, q) MoveFile(p, q)
00162 #else
00163 #define REMOVE_FILE(s) _wremove(s)
00164 #define RENAME_FILE(p, q) _wrename(p, q)
00165 #endif
00166 #define GETENV(x)     _wgetenv(x)
00167 #define T_EOF         WEOF
00168 #ifndef STD_STRING
00169 #define STD_STRING    std::wstring
00170 #endif
00171 #ifndef _T
00172 #define _T(x) L##x
00173 #endif
00174 #else
00175 typedef char char_t;
00176 #define STRLEN(x)     strlen(x)
00177 #define STRCHR(x, y)  strchr(x, y)
00178 #define STRCMP(x, y)  strcmp(x, y)
00179 #define STRCPY(x, y)  strcpy(x, y)
00180 #define STRNCPY(x,y,z) strncpy(x, y, z)
00181 #define STRCOLL(x, y) strcoll(x, y)
00182 #define STRNCMP(x,y,z) strncmp(x, y, z)
00183 #define STRLITERAL(x) (char*)x
00184 #define PRINTF        printf
00185 #define FPRINTF       fprintf
00186 #define SPRINTF       sprintf
00187 #define VSPRINTF      vsprintf
00188 #define FSCANF        fscanf
00189 #define SSCANF        sscanf
00190 #define GETC(x)       getc(x)
00191 #define UNGETC(x, y)  ungetc(x, y)
00192 #define TOLOWER(x)    tolower((x) & 0xFF)
00193 #define TOUPPER(x)    toupper((x) & 0xFF)
00194 #define ISALNUM(x)    isalnum((x) & 0xFF)
00195 #define STRSTR(x, y)  strstr(x, y)
00196 #define STRXFRM(x,y,z) strxfrm(x, y, z)
00197 #define STRFTIME(a,b,c,d) strftime(a,b,c,d)
00198 #define REMOVE_FILE(s)     remove(s)
00199 #define RENAME_FILE(p, q)  rename(p, q)
00200 #define GETENV(x)     getenv(x)
00201 #ifndef STD_STRING
00202 #define STD_STRING    std::string
00203 #endif
00204 #define T_EOF         EOF
00205 #ifdef _T
00206 #undef _T
00207 #endif
00208 #define _T(x) x
00209 #endif
00210 
00211 inline void strlower(char_t* dst, const char_t* src)
00212 {
00213     int ch;
00214     do {
00215         ch = *src++;
00216         *dst++ = TOLOWER(ch);
00217     } while (ch != 0);
00218 }
00219 
00220 typedef signed char    db_int1;
00221 typedef unsigned char  db_nat1;
00222 
00223 typedef signed short   db_int2;
00224 typedef unsigned short db_nat2;
00225 
00226 typedef signed int     db_int4;
00227 typedef unsigned int   db_nat4;
00228 
00229 typedef unsigned char  db_byte;
00230 
00231 typedef float  db_real4;
00232 typedef double db_real8;
00233 
00234 #if defined(_WIN32) && !defined(__MINGW32__)
00235 typedef unsigned __int64 db_nat8;
00236 typedef __int64          db_int8;
00237 #if defined(__IBMCPP__)
00238 #define INT8_FORMAT "%lld"
00239 #define T_INT8_FORMAT _T("%lld")
00240 #else
00241 #define INT8_FORMAT "%I64d"
00242 #define T_INT8_FORMAT _T("%I64d")
00243 #endif
00244 #define CONST64(c)  c
00245 #else
00246 #if SIZEOF_LONG == 8
00247 typedef unsigned long db_nat8;
00248 typedef signed   long db_int8;
00249 #define INT8_FORMAT "%ld"
00250 #define T_INT8_FORMAT _T("%ld")
00251 #define CONST64(c)  c##L
00252 #else
00253 typedef unsigned long long db_nat8;
00254 typedef signed   long long db_int8;
00255 #ifdef __MINGW32__
00256 #define INT8_FORMAT "%I64d"
00257 #define T_INT8_FORMAT _T("%I64d")
00258 #else
00259 #define INT8_FORMAT "%lld"
00260 #define T_INT8_FORMAT _T("%lld")
00261 #endif
00262 #define CONST64(c)  c##LL
00263 #endif
00264 #endif
00265 
00266 // This mapping is done for compatibility reasons
00267 typedef db_int1 int1;
00268 typedef db_nat1 nat1;
00269 typedef db_int2 int2;
00270 typedef db_nat2 nat2;
00271 typedef db_int4 int4;
00272 typedef db_nat4 nat4;
00273 
00274 typedef db_byte byte;
00275 
00276 typedef db_real4 real4;
00277 typedef db_real8 real8;
00278 
00279 typedef db_nat8 nat8;
00280 
00281 #ifndef INT8_IS_DEFINED
00282 typedef db_int8 int8;
00283 #endif
00284 
00285 
00286 #if !defined(bool) && (defined(__SUNPRO_CC) || defined(__IBMCPP__))
00287 #define bool  char
00288 #define true  (1)
00289 #define false (0)
00290 #endif
00291 
00292 #define nat8_low_part(x)  ((db_nat4)(x))
00293 #define int8_low_part(x)  ((db_int4)(x))
00294 #if defined(_MSC_VER) // bug in MVC 6.0
00295 #define nat8_high_part(x) (sizeof(x) < 8 ? 0 : ((db_nat4)((db_nat8)(x)>>32)))
00296 #define int8_high_part(x) (sizeof(x) < 8 ? 0 : ((db_int4)((db_int8)(x)>>32)))
00297 #else
00298 #define nat8_high_part(x) ((db_nat4)((db_nat8)(x)>>32))
00299 #define int8_high_part(x) ((db_int4)((db_int8)(x)>>32))
00300 #endif
00301 
00302 #define cons_nat8(hi, lo) ((((db_nat8)(hi)) << 32) | (db_nat4)(lo))
00303 #define cons_int8(hi, lo) ((((db_int8)(hi)) << 32) | (db_nat4)(lo))
00304 
00305 #define MAX_NAT8  db_nat8(-1)
00306 
00307 #ifndef BIG_ENDIAN
00308 #define BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
00309 #endif
00310 #ifndef LITTLE_ENDIAN
00311 #define LITTLE_ENDIAN   1234
00312 #endif
00313 
00314 #ifndef BYTE_ORDER
00315 #if defined(__sparc__) || defined(__m68k__)
00316 #define BYTE_ORDER      BIG_ENDIAN
00317 #else
00318 #define BYTE_ORDER      LITTLE_ENDIAN
00319 #endif
00320 #endif
00321 
00322 #if defined(_WIN32)
00323 typedef HANDLE descriptor_t;
00324 #else
00325 typedef int descriptor_t;
00326 #endif
00327 
00328 #if !defined(_fastcall) && (!defined(_WIN32) || defined(__IBMCPP__) || defined(__MINGW32__))
00329 #define _fastcall
00330 #endif
00331 
00332 #if defined(_WIN32) || !defined(NO_PTHREADS)
00333 #define THREADS_SUPPORTED 1
00334 #else
00335 #define THREADS_SUPPORTED 0
00336 #endif
00337 
00338 #define itemsof(array) (sizeof(array)/sizeof*(array))
00339 
00340 extern GIGABASE_DLL_ENTRY byte* dbMalloc(size_t size);
00341 extern GIGABASE_DLL_ENTRY void  dbFree(void* ptr);
00342 
00343 #if defined(__BCPLUSPLUS__)
00344 #define qsort(arr, n, s, cmp) std::qsort(arr, n, s, cmp)
00345 #endif
00346 
00347 #ifndef __IBMCPP__
00348 END_GIGABASE_NAMESPACE
00349 #endif
00350 
00351 #endif
00352 
00353 

Generated on Thu Feb 12 18:46:27 2004 for GigaBASE by doxygen 1.3.5