X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.cc;h=06d531c0269a69d93f96e8a53abace26d408b9e7;hb=48e002c85474560e93187b1423a75dde49463147;hp=a5349100137cb5434ff65ec61c6565953b3bbd3c;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Utils/Exception.cc b/Utils/Exception.cc index a534910..06d531c 100644 --- a/Utils/Exception.cc +++ b/Utils/Exception.cc @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2006 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,21 +20,49 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief Exception non-inline non-template implementation */ #include "Exception.hh" //#include "Exception.ih" // Custom includes -#include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ char const * satcom::lib::SystemException::what() - const throw() +prefix_ void senf::throwErrno(std::string const & where, int code) { - return std::strerror(this->err); +#ifndef SENF_NO_ERRNOEXC + switch (code) { + + // BOOST_PP_REPEAT is limited to 256 repetitions. The max errno value I found in any header file + // was somewhere around 530 or so. I assume going to 1024 will be good enough. This explicit + // code will be optimized into a jump table by g++ (which is more efficient than trying to do + // the table oneself) + +# define ExceptionCase(z, n, data) case n: throw ErrnoException(where); + BOOST_PP_REPEAT(256, ExceptionCase, _) ; +# undef ExceptionCase + +# define ExceptionCase(z, n, data) case 256+n: throw ErrnoException<256+n>(where); + BOOST_PP_REPEAT(256, ExceptionCase, _) ; +# undef ExceptionCase + +# define ExceptionCase(z, n, data) case 512+n: throw ErrnoException<512+n>(where); + BOOST_PP_REPEAT(256, ExceptionCase, _) ; +# undef ExceptionCase + +# define ExceptionCase(z, n, data) case 768+n: throw ErrnoException<768+n>(where); + BOOST_PP_REPEAT(256, ExceptionCase, _) ; +# undef ExceptionCase + + default: + throw SystemException(where, code); + } +#else + throw SystemException(where, code); +#endif } ///////////////////////////////cc.e//////////////////////////////////////// @@ -43,5 +71,10 @@ prefix_ char const * satcom::lib::SystemException::what() // Local Variables: // mode: c++ -// c-file-style: "satcom" +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: