X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cci;h=84f5d7b0e058f095491995a20606d98d62da3055;hb=1d247d12d1759ffd77f456efe3a52f03dd289994;hp=40d89a5f6106aff1326a4ac74c0a5c4800f1c5df;hpb=445c71d8d242f4ce3d23d8db8d1faf909943cfec;p=senf.git diff --git a/Utils/Exception.cci b/Utils/Exception.cci index 40d89a5..84f5d7b 100644 --- a/Utils/Exception.cci +++ b/Utils/Exception.cci @@ -27,25 +27,27 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ senf::SystemException::SystemException(SystemException const & other) - : std::stringstream(other.str(),std::ios::out), code_(other.code_) +/////////////////////////////////////////////////////////////////////////// +// senf::Exception +prefix_ senf::Exception::Exception(std::string const & description) + : message_(description) {} -prefix_ senf::SystemException::SystemException(std::string const & where, int code) - : std::stringstream(std::ios::out), code_(code) +/////////////////////////////////////////////////////////////////////////// + +prefix_ senf::SystemException::SystemException(std::string const & where) { - if (! where.empty()) - (*this) << where << ": "; - (*this) << "(" << code_ << ") " << description(); + init(where, errno); } -prefix_ char const * senf::SystemException::what() - const throw() +prefix_ senf::SystemException::SystemException(int code) +{ + init("", code); +} + +prefix_ senf::SystemException::SystemException(std::string const & where, int code) { - /// \fixme Replace the 'stringstream' base-class with our own stream with a specialized - /// streambuf which allows to efficiently access the contents as a C string. - buffer_ = this->str(); - return buffer_.c_str(); + init(where, code); } prefix_ int senf::SystemException::errorNumber() @@ -80,19 +82,12 @@ prefix_ senf::SystemException::~SystemException() throw() {} -prefix_ void senf::throwErrno() +prefix_ void senf::SystemException::init(std::string const & where, int code) { - throwErrno("", errno); -} - -prefix_ void senf::throwErrno(std::string const & where) -{ - throwErrno(where, errno); -} - -prefix_ void senf::throwErrno(int code) -{ - throwErrno("", code); + code_ = code; + if (! where.empty()) + (*this) << where << ": "; + (*this) << "(" << code << ") " << description(); } ///////////////////////////////cci.e///////////////////////////////////////