#ifndef _zexception_hpp_ #define _zexception_hpp_ #include #include #include #define DEF_EXCEPTION(clsname)\ class clsname##_exception:public std::exception\ {\ std::string m_what;\ public:\ clsname##_exception(const std::string&msg) throw():m_what(msg) { } \ ~clsname##_exception() throw() { } \ const char* what() const throw() { return m_what.c_str(); }\ }; inline const char*eformat(char*buf,const char*fmt,...) { va_list ap; va_start(ap, fmt); vsprintf(buf,fmt,ap); va_end(ap); return buf; } #define THROW_EXCEPTION(clsname,fmt,...) {\ char ___fmt0[512]; \ char ___buf[2048]; \ sprintf(___fmt0,"[%s:%d]%s",__FILE__,__LINE__,fmt);\ eformat(___buf,fmt,##__VA_ARGS__);\ throw clsname##_exception(___buf);\ } #endif