00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #if !defined escript_EsysAssert_20040330_H
00016 #define escript_EsysAssert_20040330_H
00017 #include "system_dep.h"
00029
00030
00031
00032
00033
00034
00035
00036 #undef EsysAssert
00037
00038 #if defined DOASSERT
00039
00040
00041
00042
00043
00044 #include "EsysAssertException.h"
00045 #include <sstream>
00046
00047 namespace esysUtils {
00048
00049 class ErrStream
00050 {
00051 public:
00052 template <typename Tmpl>
00053 ErrStream& operator<<(Tmpl t)
00054 {
00055 std::stringstream str;
00056 str << t;
00057 m_msg += str.str();
00058
00059 return *this;
00060 }
00061
00062 inline
00063 const std::string &toString() const
00064 {
00065 return m_msg;
00066 }
00067
00068 private:
00069 std::string m_msg;
00070 };
00071
00072 inline
00073 std::ostream& operator<<(std::ostream& oStream,
00074 const ErrStream& errStream)
00075 {
00076 oStream << errStream.toString();
00077 return oStream;
00078 }
00079
00080 }
00081
00082 #define EsysAssert(AssertTest,AssertMessage) \
00083 (void)((AssertTest) || \
00084 ((esysUtils::EsysAssertException::assertFailure(#AssertTest, __DATE__, __FILE__, __LINE__, \
00085 (esysUtils::ErrStream()<<AssertMessage).toString())),0),0)
00086
00087 #else
00088
00089
00090
00091
00092
00093 #define EsysAssert(AssertTest,AssertMessage) ((void)0)
00094
00095 #endif
00096
00097 #endif