|
Katana Plug-in APIs 0.1
|
00001 // Copyright (c) 2011 The Foundry Visionmongers Ltd. All Rights Reserved. 00002 #ifndef INCLUDED_FNGEOLIBUTIL_ASSERTEXCEPTION_H 00003 #define INCLUDED_FNGEOLIBUTIL_ASSERTEXCEPTION_H 00004 00005 #include <exception> 00006 00007 #include <FnGeolib/FnGeolibAPI.h> 00008 #include <FnGeolib/util/ns.h> 00009 00010 FNGEOLIBUTIL_NAMESPACE_ENTER 00011 { 00012 00014 00015 class FNGEOLIB_API AssertException : public std::exception 00016 { 00017 public: 00019 00022 AssertException(const char* msg) throw() : msg_(msg) {} 00023 00025 00027 virtual const char* what() const throw() { return msg_; } 00028 00029 private: 00031 const char* msg_; 00032 }; 00033 00034 // macro magic to ensure assert message is always constant 00035 #define FNGEOLIBUTIL_STRINGIZE_DETAIL(x) #x 00036 #define FNGEOLIBUTIL_STRINGIZE(x) FNGEOLIBUTIL_STRINGIZE_DETAIL(x) 00037 #define FNGEOLIBUTIL_EXCEPTION_ASSERT_STRING(msg) ("assertion(" msg ") failed at " __FILE__ ": " FNGEOLIBUTIL_STRINGIZE(__LINE__)) 00038 00039 #define exception_assert(x) do { if (!(x)) throw FNGEOLIBUTIL_NAMESPACE::AssertException(FNGEOLIBUTIL_EXCEPTION_ASSERT_STRING(#x)); } while (0) 00040 //#define exception_assert(x) (void)sizeof((x)) // use this version to disable without introducing warnings 00041 00042 } 00043 FNGEOLIBUTIL_NAMESPACE_EXIT 00044 00045 #endif // INCLUDED_FNGEOLIBUTIL_ASSERTEXCEPTION_H
1.7.3