00001 /* 00002 __________ 00003 _____ __ __\______ \_____ _______ ______ ____ _______ 00004 / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ 00005 | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ 00006 |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| 00007 \/ \/ \/ \/ 00008 Copyright (C) 2004-2008 Ingo Berg 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy of this 00011 software and associated documentation files (the "Software"), to deal in the Software 00012 without restriction, including without limitation the rights to use, copy, modify, 00013 merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 00014 permit persons to whom the Software is furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in all copies or 00017 substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 00020 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00021 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00022 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 */ 00025 00026 #ifndef MU_PARSER_FIXES_H 00027 #define MU_PARSER_FIXES_H 00028 00033 // 00034 // Compatibility fixes 00035 // 00036 00037 //--------------------------------------------------------------------------- 00038 // 00039 // Intel Compiler 00040 // 00041 //--------------------------------------------------------------------------- 00042 00043 #ifdef __INTEL_COMPILER 00044 00045 // remark #981: operands are evaluated in unspecified order 00046 // disabled -> completely pointless if the functions do not have side effects 00047 // 00048 #pragma warning(disable:981) 00049 00050 // remark #383: value copied to temporary, reference to temporary used 00051 #pragma warning(disable:383) 00052 00053 // remark #1572: floating-point equality and inequality comparisons are unreliable 00054 // disabled -> everyone knows it, the parser passes this problem 00055 // deliberately to the user 00056 #pragma warning(disable:1572) 00057 00058 #endif 00059 00060 00061 //--------------------------------------------------------------------------- 00062 // 00063 // MSVC6 00064 // 00065 //--------------------------------------------------------------------------- 00066 00067 00068 #if defined(_MSC_VER) && _MSC_VER==1200 00069 00077 #define auto_ptr _my_auto_ptr 00078 00079 // This is another stupidity that needs to be undone in order to de-pollute 00080 // the global namespace! 00081 #undef min 00082 #undef max 00083 00084 00085 namespace std 00086 { 00087 typedef ::size_t size_t; 00088 00089 //--------------------------------------------------------------------------- 00096 inline int rand(void) 00097 { 00098 return ::rand(); 00099 } 00100 00101 //--------------------------------------------------------------------------- 00108 inline size_t strlen(const char *szMsg) 00109 { 00110 return ::strlen(szMsg); 00111 } 00112 00113 //--------------------------------------------------------------------------- 00120 inline int strncmp(const char *a, const char *b, size_t len) 00121 { 00122 return ::strncmp(a,b,len); 00123 } 00124 00125 //--------------------------------------------------------------------------- 00126 template<typename T> 00127 T max(T a, T b) 00128 { 00129 return (a>b) ? a : b; 00130 } 00131 00132 //--------------------------------------------------------------------------- 00133 template<typename T> 00134 T min(T a, T b) 00135 { 00136 return (a<b) ? a : b; 00137 } 00138 00139 //--------------------------------------------------------------------------- 00145 template<class _Ty> 00146 class _my_auto_ptr 00147 { 00148 public: 00149 typedef _Ty element_type; 00150 00151 explicit _my_auto_ptr(_Ty *_Ptr = 0) 00152 :_Myptr(_Ptr) 00153 {} 00154 00155 _my_auto_ptr(_my_auto_ptr<_Ty>& _Right) 00156 :_Myptr(_Right.release()) 00157 {} 00158 00159 template<class _Other> 00160 operator _my_auto_ptr<_Other>() 00161 { 00162 return (_my_auto_ptr<_Other>(*this)); 00163 } 00164 00165 template<class _Other> 00166 _my_auto_ptr<_Ty>& operator=(_my_auto_ptr<_Other>& _Right) 00167 { 00168 reset(_Right.release()); 00169 return (*this); 00170 } 00171 00172 ~auto_ptr() { delete _Myptr; } 00173 _Ty& operator*() const { return (*_Myptr); } 00174 _Ty *operator->() const { return (&**this); } 00175 _Ty *get() const { return (_Myptr); } 00176 00177 _Ty *release() 00178 { 00179 _Ty *_Tmp = _Myptr; 00180 _Myptr = 0; 00181 return (_Tmp); 00182 } 00183 00184 void reset(_Ty* _Ptr = 0) 00185 { 00186 if (_Ptr != _Myptr) 00187 delete _Myptr; 00188 _Myptr = _Ptr; 00189 } 00190 00191 private: 00192 _Ty *_Myptr; 00193 }; // class _my_auto_ptr 00194 } // namespace std 00195 00196 #endif // Microsoft Visual Studio Version 6.0 00197 00198 #endif // include guard 00199 00200