18 #if defined(__GNUC__) && defined(__GNUC_MINOR__) 19 # define MRPT_CHECK_GCC_VERSION( major, minor ) ( ( __GNUC__ > (major) ) || ( __GNUC__ == (major) && __GNUC_MINOR__ >= (minor) ) ) 21 # define MRPT_CHECK_GCC_VERSION( major, minor ) 0 26 # define MRPT_VISUALC_VERSION(major) 0 27 # define MRPT_CHECK_VISUALC_VERSION(major) 0 35 # define MRPT_VISUALC_VERSION(major) ( (6 + (major >= 14 ? (-1) : 0) + major) * 100 ) 36 # define MRPT_CHECK_VISUALC_VERSION(major) ( _MSC_VER >= MRPT_VISUALC_VERSION(major) ) 40 # define __has_feature(x) 0 // Compatibility with non-clang compilers. 42 #ifndef __has_extension 43 # define __has_extension __has_feature // Compatibility with pre-3.0 compilers. 48 #if (__cplusplus>199711L || MRPT_CHECK_VISUALC_VERSION(11) ) 49 # define MRPT_HAS_CXX11 1 51 # define MRPT_HAS_CXX11 0 56 # define MRPT_OVERRIDE override 58 # define MRPT_OVERRIDE 62 #if MRPT_CHECK_VISUALC_VERSION(12) || __has_extension(cxx_deleted_functions) || (MRPT_CHECK_GCC_VERSION(4,4) && MRPT_HAS_CXX11) 63 # define MRPT_DELETED_FUNC =delete 65 # define MRPT_DELETED_FUNC 69 #if MRPT_CHECK_VISUALC_VERSION(14) || __has_extension(cxx_noexcept) || (MRPT_CHECK_GCC_VERSION(4,6) && MRPT_HAS_CXX11) 70 # define MRPT_NO_THROWS noexcept 72 # define MRPT_NO_THROWS throw() 76 #if MRPT_CHECK_VISUALC_VERSION(10) || (MRPT_CHECK_GCC_VERSION(4,4) || defined(__clang__)) && (MRPT_HAS_CXX11 || defined(__GXX_EXPERIMENTAL_CXX0X__)) 77 # define MRPT_HAS_UNIQUE_PTR 1 79 # define MRPT_HAS_UNIQUE_PTR 0 84 #if defined(__clang__) && defined(__has_extension) 85 # if __has_extension(attribute_deprecated_with_message) 86 # define MRPT_DEPRECATED(msg) __attribute__((deprecated(msg))) 88 # define MRPT_DEPRECATED(msg) __attribute__((deprecated)) 90 #elif MRPT_CHECK_GCC_VERSION(4, 5) 91 # define MRPT_DEPRECATED(msg) __attribute__((deprecated(msg))) 92 #elif MRPT_CHECK_VISUALC_VERSION(8) 93 # define MRPT_DEPRECATED(msg) __declspec(deprecated("deprecated: " msg)) 95 # define MRPT_DEPRECATED(msg) 100 #if defined(_MSC_VER) 101 #define MRPT_DO_PRAGMA(x) __pragma(x) 102 #define __STR2__(x) #x 103 #define __STR1__(x) __STR2__(x) 104 #define __MSVCLOC__ __FILE__ "("__STR1__(__LINE__)") : " 105 #define MRPT_MSG_PRAGMA(_msg) MRPT_DO_PRAGMA(message (__MSVCLOC__ _msg)) 106 #elif defined(__GNUC__) 107 #define MRPT_DO_PRAGMA(x) _Pragma (#x) 108 #define MRPT_MSG_PRAGMA(_msg) MRPT_DO_PRAGMA(message (_msg)) 110 #define MRPT_DO_PRAGMA(x) 111 #define MRPT_MSG_PRAGMA(_msg) 114 #define MRPT_WARNING(x) MRPT_MSG_PRAGMA("Warning: " x) 115 #define MRPT_TODO(x) MRPT_MSG_PRAGMA("TODO: " x) 119 # define MRPT_printf_format_check(_FMT_,_VARARGS_) __attribute__ ((__format__ (__printf__, _FMT_,_VARARGS_))) 121 # define MRPT_printf_format_check(_FMT_,_VARARGS_) 125 # define MRPT_scanf_format_check(_FMT_,_VARARGS_) __attribute__ ((__format__ (__scanf__, _FMT_,_VARARGS_))) 127 # define MRPT_scanf_format_check(_FMT_,_VARARGS_) 131 #if defined(_MSC_VER) 132 #define MRPT_ALIGN16 __declspec(align(16)) 133 #define MRPT_ALIGN32 __declspec(align(32)) 134 #elif defined(__GNUC__) 135 #define MRPT_ALIGN16 __attribute__((aligned(16))) 136 #define MRPT_ALIGN32 __attribute__((aligned(32))) 143 #if defined(_MSC_VER) && (_MSC_VER>=1300) 144 #define __CURRENT_FUNCTION_NAME__ __FUNCTION__ 146 #define __CURRENT_FUNCTION_NAME__ __PRETTY_FUNCTION__ 154 #define THROW_EXCEPTION(msg) \ 156 std::ostringstream auxCompStr;\ 157 auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\ 158 auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\ 159 auxCompStr << msg << std::endl; \ 160 throw std::logic_error( auxCompStr.str() );\ 163 #define THROW_EXCEPTION_FMT(_FORMAT_STRING,...) \ 164 THROW_EXCEPTION(mrpt::format(_FORMAT_STRING,__VA_ARGS__)) 170 #define THROW_TYPED_EXCEPTION(msg,exceptionClass) \ 172 std::ostringstream auxCompStr;\ 173 auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\ 174 auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\ 175 auxCompStr << msg << std::endl; \ 176 throw exceptionClass( auxCompStr.str() );\ 179 #define THROW_TYPED_EXCEPTION_FMT(exceptionClass,_FORMAT_STRING,...) \ 180 THROW_TYPED_EXCEPTION(mrpt::format(_FORMAT_STRING,__VA_ARGS__), exceptionClass) 185 #define THROW_STACKED_EXCEPTION(e) \ 187 std::string _tse_str(e.what());\ 188 _tse_str+= mrpt::format(" %s:%i: In `%s`\n", __FILE__,__LINE__, __CURRENT_FUNCTION_NAME__);\ 189 throw std::logic_error( _tse_str );\ 196 #define THROW_STACKED_EXCEPTION_CUSTOM_MSG1(e,msg) \ 198 std::ostringstream auxCompStr;\ 199 auxCompStr << e.what() ; \ 200 auxCompStr << msg << std::endl; \ 201 throw std::logic_error( auxCompStr.str() );\ 208 #define THROW_STACKED_EXCEPTION_CUSTOM_MSG2(e,stuff,param1) \ 210 std::ostringstream auxCompStr;\ 211 auxCompStr << e.what() ; \ 212 auxCompStr << mrpt::format( stuff, param1 ) << std::endl; \ 213 throw std::logic_error( auxCompStr.str() );\ 217 #define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V) THROW_EXCEPTION(mrpt::format("Cannot parse object: unknown serialization version number: '%i'",static_cast<int>(__V))) 225 # define ASSERTMSG_(f,__ERROR_MSG) \ 227 if (!(f)) THROW_EXCEPTION( ::std::string( __ERROR_MSG ) ); \ 234 # define ASSERT_(f) \ 235 ASSERTMSG_(f, std::string("Assert condition failed: ") + ::std::string(#f) ) 239 #define MRPT_CHECK_NORMAL_NUMBER(v) \ 241 if (math::isNaN(v)) THROW_EXCEPTION("Check failed (value is NaN)"); \ 242 if (!math::isFinite(v)) THROW_EXCEPTION("Check failed (value is not finite)"); \ 246 #if MRPT_CHECK_VISUALC_VERSION(10) || __has_extension(cxx_static_assert) || (MRPT_CHECK_GCC_VERSION(4,3) && MRPT_HAS_CXX11) 247 #define MRPT_COMPILE_TIME_ASSERT(expression) static_assert(expression,#expression); 256 template <
bool value>
struct compile_time_assert;
257 template <>
struct compile_time_assert<true> {
enum {
value=1}; };
260 #define MRPT_COMPILE_TIME_ASSERT(expression) \ 261 typedef char BOOST_JOIN(MRPT_CTA, __LINE__)[::mrpt::utils::compile_time_assert<(bool)(expression)>::value]; extern BOOST_JOIN(MRPT_CTA, __LINE__) BOOST_JOIN(MRPT_DUMMYVAR_CTA, __LINE__); 266 #define ASSERT_EQUAL_( __A, __B) { if (__A!=__B) { std::ostringstream __s__;__s__<<"ASSERT_EQUAL_("<<#__A<<","<<#__B<<") failed with\n"<<#__A<<"=" <<__A <<"\n"<<#__B<<"="<<__B; THROW_EXCEPTION(__s__.str()) } } 267 #define ASSERT_NOT_EQUAL_( __A, __B) { if (__A==__B) { std::ostringstream __s__;__s__<<"ASSERT_NOT_EQUAL_("<<#__A<<","<<#__B<<") failed with\n"<<#__A<<"=" <<__A <<"\n"<<#__B<<"="<<__B; THROW_EXCEPTION(__s__.str()) } } 268 #define ASSERT_BELOW_( __A, __B) { if (__A>=__B) { std::ostringstream __s__;__s__<<"ASSERT_BELOW_("<<#__A<<","<<#__B<<") failed with\n"<<#__A<<"=" <<__A <<"\n"<<#__B<<"="<<__B; THROW_EXCEPTION(__s__.str()) } } 269 #define ASSERT_ABOVE_( __A, __B) { if (__A<=__B) { std::ostringstream __s__;__s__<<"ASSERT_ABOVE_("<<#__A<<","<<#__B<<") failed with\n"<<#__A<<"=" <<__A <<"\n"<<#__B<<"="<<__B; THROW_EXCEPTION(__s__.str()) } } 270 #define ASSERT_BELOWEQ_( __A, __B) { if (__A>__B) { std::ostringstream __s__;__s__<<"ASSERT_BELOWEQ_("<<#__A<<","<<#__B<<") failed with\n"<<#__A<<"=" <<__A <<"\n"<<#__B<<"="<<__B; THROW_EXCEPTION(__s__.str()) } } 271 #define ASSERT_ABOVEEQ_( __A, __B) { if (__A<__B) { std::ostringstream __s__;__s__<<"ASSERT_ABOVEEQ_("<<#__A<<","<<#__B<<") failed with\n"<<#__A<<"=" <<__A <<"\n"<<#__B<<"="<<__B; THROW_EXCEPTION(__s__.str()) } } 273 #define ASSERT_FILE_EXISTS_(FIL) ASSERTMSG_( mrpt::system::fileExists(FIL), std::string("Assert file existence failed: ") + ::std::string(FIL) ) 274 #define ASSERT_DIRECTORY_EXISTS_(DIR) ASSERTMSG_( mrpt::system::directoryExists(DIR), std::string("Assert directory existence failed: ") + ::std::string(DIR) ) 276 #else // MRPT_HAS_ASSERT 277 # define ASSERTMSG_(f,__ERROR_MSG) { } 278 # define ASSERT_(f) { } 279 # define MRPT_CHECK_NORMAL_NUMBER(val) { } 280 # define MRPT_COMPILE_TIME_ASSERT(f) { } 281 # define ASSERT_EQUAL_( __A, __B) { } 282 # define ASSERT_NOT_EQUAL_( __A, __B) { } 283 # define ASSERT_BELOW_( __A, __B) { } 284 # define ASSERT_ABOVE_( __A, __B) { } 285 # define ASSERT_BELOWEQ_( __A, __B) { } 286 # define ASSERT_ABOVEEQ_( __A, __B) { } 288 # define ASSERT_FILE_EXISTS_(FIL) { } 289 # define ASSERT_DIRECTORY_EXISTS_(DIR) { } 290 #endif // MRPT_HAS_ASSERT 297 # define ASSERTDEB_(f) ASSERT_(f) 298 # define ASSERTDEBMSG_(f,__ERROR_MSG) ASSERTMSG_(f,__ERROR_MSG) 300 # define ASSERTDEB_(f) { } 301 # define ASSERTDEBMSG_(f,__ERROR_MSG) { } 307 #define MRPT_UNUSED_PARAM(a) (void)(a) 309 #if MRPT_HAS_STACKED_EXCEPTIONS 313 # define MRPT_TRY_START \ 319 # define MRPT_TRY_END \ 321 catch (std::bad_alloc &) \ 323 catch (std::exception &e) \ 325 THROW_STACKED_EXCEPTION(e); \ 329 THROW_EXCEPTION("Unexpected runtime error!"); \ 335 # define MRPT_TRY_END_WITH_CLEAN_UP(stuff) \ 337 catch (std::bad_alloc &) \ 339 catch (std::exception &e) \ 342 THROW_STACKED_EXCEPTION(e); \ 347 THROW_EXCEPTION("Unexpected runtime error!"); \ 351 # define MRPT_TRY_START 352 # define MRPT_TRY_END 353 # define MRPT_TRY_END_WITH_CLEAN_UP(stuff) 356 #if MRPT_ENABLE_EMBEDDED_GLOBAL_PROFILER 357 # define MRPT_PROFILE_FUNC_START ::mrpt::utils::CProfilerProxy BOOST_JOIN(__dum_var,__LINE__)( __CURRENT_FUNCTION_NAME__); 359 # define MRPT_PROFILE_FUNC_START 367 MRPT_PROFILE_FUNC_START \ 373 #define MRPT_END_WITH_CLEAN_UP(stuff) \ 374 MRPT_TRY_END_WITH_CLEAN_UP(stuff) 380 # define M_2PI 6.283185307179586476925286766559 // The 2*PI constant 383 #define M_PIf 3.14159265358979f 384 #define M_2PIf 6.28318530717959f 386 #if defined(HAVE_LONG_DOUBLE) && !defined(M_PIl) 387 # define M_PIl 3.14159265358979323846264338327950288L 388 # define M_2PIl (2.0L*3.14159265358979323846264338327950288L) 394 # define MRPT_printf_format_check(_FMT_,_VARARGS_) __attribute__ ((__format__ (__printf__, _FMT_,_VARARGS_))) 396 # define MRPT_printf_format_check(_FMT_,_VARARGS_) 401 # define MRPT_scanf_format_check(_FMT_,_VARARGS_) __attribute__ ((__format__ (__scanf__, _FMT_,_VARARGS_))) 403 # define MRPT_scanf_format_check(_FMT_,_VARARGS_) 408 #if (defined _MSC_VER) || (defined __INTEL_COMPILER) 409 #define MRPT_FORCE_INLINE __forceinline 411 #define MRPT_FORCE_INLINE inline 426 #define QUOTE(name) #name 427 #define STR(macro) QUOTE(macro) 428 #define USIZE_STR STR(PRIuSIZE) 431 #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) || defined (_M_X64) \ 432 || defined (__i386__)|| defined (__i386) || defined (_M_I86) || defined (i386) || defined(_M_IX86) || defined (_X86_) 433 # define MRPT_IS_X86_AMD64 1 #define MRPT_printf_format_check(_FMT_, _VARARGS_)
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLsizei const GLfloat * value