00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __ERROR_HPP
00017 #define __ERROR_HPP
00018
00019 #include <boost/shared_ptr.hpp>
00020 #include <exception>
00021 #include <stdarg.h>
00022 #include <sstream>
00023
00024 class Error;
00025
00027 typedef boost::shared_ptr< Error > ErrorPtr;
00028
00054 class Error: public std::exception {
00055 public:
00057 Error(void) {}
00059 virtual ~Error(void) throw() {}
00061 Error( const Error &aError );
00063 template< typename T >
00064 std::ostream &operator<<( const T &t ) { msgStream << t; return msgStream; }
00069 std::ostream &operator<<( std::ostream& (*__pf)( std::ostream&) )
00070 { (*__pf)( msgStream ); return msgStream; }
00072 virtual const char *what(void) const throw();
00073 protected:
00075 std::ostringstream msgStream;
00078 static std::string message;
00079 };
00080
00081 #define ERRORMACRO( condition, class, params, message ) \
00082 if ( !( condition ) ) { \
00083 class _e params; \
00084 _e << message; \
00085 throw _e; \
00086 };
00087
00088 #endif