global.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: global.h,v 1.24 2005/12/23 17:01:39 amoll Exp $
00005 //
00006 
00007 #ifndef BALL_COMMON_GLOBAL_H
00008 #define BALL_COMMON_GLOBAL_H
00009 
00010 #ifndef BALL_CONFIG_CONFIG_H
00011 # include <BALL/CONFIG/config.h>
00012 #endif
00013 
00014 #include <limits.h>
00015 #include <time.h>
00016 
00017 #ifdef BALL_HAS_BASETSD_H
00018 # include <basetsd.h>
00019 #endif
00020 
00021 // If possible use the ISO C99-compliant header stdint.h
00022 // to define the portable integer types.
00023 #ifdef BALL_HAS_STDINT_H
00024 # include <stdint.h>
00025 #endif
00026 
00027 // Added to avoid warnings with MS Visual Studio .NET
00028 #ifdef BALL_COMPILER_MSVC
00029 # pragma warning( disable : 4290 )
00030 # pragma warning( disable : 4251 ) // Warnings about DLL interface 
00031 # pragma warning( disable : 4275 ) // Warnings about DLL interface (we should do something about them, though)
00032 #endif
00033 
00034 #ifdef BALL_COMPILER_MSVC
00035 # ifdef BALL_BUILD_DLL
00036 #   define BALL_EXPORT __declspec(dllexport)
00037 #   define BALL_EXTERN_VARIABLE __declspec(dllexport) extern
00038 # else
00039 #   define BALL_EXPORT __declspec(dllimport)
00040 #   define BALL_EXTERN_VARIABLE __declspec(dllimport) extern
00041 # endif
00042 # ifdef BALL_VIEW_BUILD_DLL
00043 #   define BALL_VIEW_EXPORT __declspec(dllexport)
00044 # else
00045 #   define BALL_VIEW_EXPORT __declspec(dllimport)
00046 # endif
00047 #else
00048 # define BALL_EXPORT
00049 # define BALL_VIEW_EXPORT
00050 # define BALL_EXTERN_VARIABLE extern
00051 #endif
00052 
00053 //This declares a BALL_DEPRECATED macro that can be used to mark deprecated api
00054 //It is essentially copied from Qt 4.4.1 but simplified, thus there might be
00055 //some cases where it does not work as expected, yet.
00056 #if defined(BALL_COMPILER_MSVC) && (_MSC_VER >= 1300)
00057     #define BALL_DEPRECATED __declspec(deprecated)
00058 #elif defined(BALL_COMPILER_GXX) && (BALL_COMPILER_VERSION_MAJOR - 0 > 3 || (BALL_COMPILER_VERSION_MAJOR - 0 == 3 && BALL_COMPILER_VERSION_MINOR - 0 >= 2))
00059     #define BALL_DEPRECATED __attribute__((deprecated))
00060 #else
00061     #define BALL_DEPRECATED
00062 #endif
00063 
00064 namespace BALL
00065 {
00066 
00067   typedef int (*ComparatorType)(const void *, const void *);
00068 
00076 
00083   typedef BALL_INDEX_TYPE Distance; 
00084 
00093   typedef BALL_SIZE_TYPE  Handle;
00094 
00102   typedef BALL_INDEX_TYPE Index;
00103 
00111   typedef BALL_SIZE_TYPE  Size;
00112 
00120   typedef BALL_LONG64_TYPE LongIndex;
00121 
00122 
00130   typedef BALL_ULONG64_TYPE LongSize;
00131 
00139   typedef time_t  Time;
00140 
00147   typedef BALL_SIZE_TYPE  HashIndex;
00148 
00156   typedef BALL_SIZE_TYPE  Position;
00157 
00164   typedef float Real;
00165 
00172   typedef double DoubleReal;
00173 
00181   typedef BALL_SIZE_TYPE Property;
00182 
00189   typedef BALL_INDEX_TYPE ErrorCode;
00190 
00191 
00199   typedef unsigned char Byte;
00200 
00208   typedef BALL_ULONG64_TYPE LongSize;
00209 
00217   typedef BALL_LONG64_TYPE LongIndex;
00218 
00223   typedef BALL_POINTERSIZEUINT_TYPE PointerSizeUInt;
00224 
00226 
00227   enum ASCII
00228   {
00229     ASCII__BACKSPACE        = '\b',
00230     ASCII__BELL             = '\a',
00231     ASCII__CARRIAGE_RETURN  = '\r',
00232     ASCII__HORIZONTAL_TAB   = '\t',
00233     ASCII__NEWLINE          = '\n',
00234     ASCII__RETURN           = ASCII__NEWLINE,
00235     ASCII__SPACE            = ' ',
00236     ASCII__TAB              = ASCII__HORIZONTAL_TAB,
00237     ASCII__VERTICAL_TAB     = '\v',
00238 
00239     ASCII__COLON            = ':',
00240     ASCII__COMMA            = ',',
00241     ASCII__EXCLAMATION_MARK = '!',
00242     ASCII__POINT            = '.',
00243     ASCII__QUESTION_MARK    = '?',
00244     ASCII__SEMICOLON        = ';'
00245   };
00246 
00247   static const Distance INVALID_DISTANCE = INT_MIN;
00248   static const Distance DISTANCE_MIN = (INT_MIN + 1);
00249   static const Distance DISTANCE_MAX = INT_MAX;
00250 
00251   static const Handle INVALID_HANDLE = INT_MAX;
00252   static const Handle HANDLE_MIN = 0 ;
00253   static const Handle HANDLE_MAX = INT_MAX - 1;
00254 
00255   static const Index INVALID_INDEX = -1;
00256   static const Index INDEX_MIN = 0;
00257   static const Index INDEX_MAX = INT_MAX;
00258 
00259   static const Position INVALID_POSITION = INT_MAX;
00260   static const Position POSITION_MIN = 0;
00261   static const Position POSITION_MAX = INT_MAX - 1;
00262 
00263 # undef SIZE_MAX
00264   static const Size INVALID_SIZE = INT_MAX;
00265   static const Size SIZE_MIN = 0;
00266   static const Size SIZE_MAX = INT_MAX - 1;
00267   
00268   
00269 }
00270 
00271 #endif // BALL_COMMON_GLOBAL_H