Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History
00001 //========================================================================== 00002 // 00003 // GTL.h - Internal header: DO NO USE IT DIRECTLY !!! 00004 // 00005 //========================================================================== 00006 // $Id: GTL.h,v 1.29 2008/02/03 18:17:08 chris Exp $ 00007 00008 #ifndef GTL_GTL_H 00009 #define GTL_GTL_H 00010 00011 #include <GTL/version.h> 00012 00013 //-------------------------------------------------------------------------- 00014 // Generic iteration over container elements 00015 //-------------------------------------------------------------------------- 00016 // 00017 // elem: loop variable 00018 // cont: container to iterate over 00019 // iter_t: iterator type 00020 // iter: prefix for begin() and end() 00021 // 00022 // contains a hack for Microsoft Visual C++ 5.0, because code like 00023 // 00024 // for(int i=0; i<10; ++i) { ... do something ... } 00025 // for(int i=0; i<10; ++i) { ... do something again ... } 00026 // 00027 // is illegal with Microsoft Extensions enabled, but without Microsoft 00028 // Extensions, the Microsoft STL does not work :-(. 00029 // So we code the line number (__LINE__) into our loop variables. 00030 00031 #define GTL_CONCAT(x, y) x##y 00032 #define GTL_FORALL_VAR(y) GTL_CONCAT(GTL_FORALL_VAR, y) 00033 00034 #define GTL_FORALL(elem, cont, iter_t, iter) \ 00035 if ((cont).iter##begin() != (cont).iter##end()) \ 00036 (elem) = *((cont).iter##begin()); \ 00037 for (iter_t GTL_FORALL_VAR(__LINE__) = (cont).iter##begin(); \ 00038 GTL_FORALL_VAR(__LINE__) != (cont).iter##end(); \ 00039 (elem) = (++GTL_FORALL_VAR(__LINE__)) == \ 00040 (cont).iter##end() ? (elem) : *GTL_FORALL_VAR(__LINE__)) 00041 00042 //-------------------------------------------------------------------------- 00043 // Configuration for GCC >= 2.8.0 00044 //-------------------------------------------------------------------------- 00045 00046 // 00047 // Using namespaces is the default; may be unset by one of the 00048 // following configurations. 00049 // 00050 00051 #define __GTL_USE_NAMESPACES 00052 00053 #ifdef __GNUC__ 00054 00055 # define __GTL_GCC 00056 00057 # if __GNUC__ == 2 && __GNUC_MINOR__ >= 8 00058 00059 # undef __GTL_USE_NAMESPACES 00060 00061 # elif __GNUC__ < 3 00062 00063 # error "Need at least version 2.8.0 of GCC to compile GTL." 00064 00065 # endif 00066 00067 // 00068 // 2/3/2008 chris: 00069 // 00070 // Enable comparison of iterators in debug mode 00071 // 00072 00073 # if __GNUC__ >= 4 00074 # undef _GLIBCXX_DEBUG 00075 # endif 00076 #endif 00077 00078 //-------------------------------------------------------------------------- 00079 // Configuration for Microsoft Visual C++ 5.0 00080 //-------------------------------------------------------------------------- 00081 00082 #ifdef _MSC_VER 00083 00084 # if _MSC_VER >= 1400 // Visual Studio 2005 00085 00086 # define _HAS_ITERATOR_DEBUGGING 0 00087 # define _CRT_SECURE_NO_DEPRECATE 1 00088 # define _SECURE_SCL 0 00089 00090 # endif 00091 00092 # if _MSC_VER >= 1100 00093 00094 # define __GTL_USE_NAMESPACES 00095 # define __GTL_MSVCC 00096 00097 # pragma warning( disable : 4786 ) 00098 # pragma warning( disable : 4251 ) 00099 00100 # if defined(GTL_STATIC) 00101 # define GTL_EXTERN 00102 # elif defined(GTL_EXPORTS) 00103 # define GTL_EXTERN __declspec(dllexport) 00104 # else 00105 # define GTL_EXTERN __declspec(dllimport) 00106 # endif 00107 00108 # else 00109 00110 # error "Need at least version 5.0 of MS Visual C++ to compile GTL." 00111 00112 # endif 00113 #else 00114 00115 # define GTL_EXTERN 00116 00117 #endif 00118 00119 //-------------------------------------------------------------------------- 00120 // Namespaces 00121 //-------------------------------------------------------------------------- 00122 00123 #ifdef __GTL_USE_NAMESPACES 00124 00125 # define __GTL_BEGIN_NAMESPACE namespace GTL { 00126 # define __GTL_END_NAMESPACE } 00127 00128 #else 00129 00130 # define __GTL_BEGIN_NAMESPACE 00131 # define __GTL_END_NAMESPACE 00132 00133 #endif 00134 00135 //-------------------------------------------------------------------------- 00136 // Temporary hack until Graphlet (i.e. gcc) supports Namespaces 00137 //-------------------------------------------------------------------------- 00138 00139 #ifdef __GTL_USE_NAMESPACES 00140 00141 namespace GTL {}; 00142 using namespace GTL; 00143 00144 namespace std {}; 00145 using namespace std; 00146 00147 #endif // __GTL_USE_NAMESPACES 00148 00149 //-------------------------------------------------------------------------- 00150 // Bugfix for EGCS & GCC < 2.95 00151 //-------------------------------------------------------------------------- 00152 00153 #if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 95 00154 00155 #include <map> 00156 #include <memory> 00157 00161 template <class T> 00162 class allocator : public alloc 00163 { 00164 }; 00165 00166 #endif 00167 00168 //-------------------------------------------------------------------------- 00169 // MSVC 6 does not define min and max in <algorithm> 00170 //-------------------------------------------------------------------------- 00171 00172 #if defined(__GTL_MSVCC) && _MSC_VER < 1300 00173 00174 #ifndef min 00175 template<class T> 00176 const T& min(const T& x, const T& y) 00177 { 00178 return ( x < y ? x : y); 00179 } 00180 #endif 00181 00182 #ifndef max 00183 template<class T> 00184 const T& max(const T& x, const T& y) 00185 { 00186 return ( x > y ? x : y); 00187 } 00188 #endif 00189 00190 #endif 00191 00192 //-------------------------------------------------------------------------- 00193 // enable debugging of memory leaks in debug mode of MSVC 00194 //-------------------------------------------------------------------------- 00195 00196 #ifdef __GTL_MSVCC 00197 # ifdef _DEBUG 00198 # define WINVER 0x0400 // compatibility with at least WinNT4 00199 // usually the followin two lines are defined in Microsoft's 00200 // generated stdafx.h 00201 # define VC_EXTRALEAN // do not include rarely used parts 00202 # include <afxwin.h> // MFC core und standard components 00203 // extra definition for check whether all needed headers are included 00204 # undef SEARCH_MEMORY_LEAKS_ENABLED 00205 # define SEARCH_MEMORY_LEAKS_ENABLED 00206 # endif // _DEBUG 00207 #endif // __GTL_MSVCC 00208 00209 #endif // GTL_GTL_H 00210 00211 //-------------------------------------------------------------------------- 00212 // end of file 00213 //--------------------------------------------------------------------------
University of Passau - FMI - Theoretical Computer Science