3 // Copyright (C) 2006 Stefan Bund <g0dil@senf.berlios.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the
17 // Free Software Foundation, Inc.,
18 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 \brief Exception inline non-template implementation */
27 #define prefix_ inline
28 ///////////////////////////////cci.p///////////////////////////////////////
30 prefix_ senf::SystemException::SystemException(SystemException const & other)
31 : std::stringstream(other.str(),std::ios::out), code_(other.code_)
34 prefix_ senf::SystemException::SystemException(std::string const & where, int code)
35 : std::stringstream(std::ios::out), code_(code)
38 (*this) << where << ": ";
39 (*this) << "(" << code_ << ") " << description();
42 prefix_ char const * senf::SystemException::what()
45 /// \fixme Replace the 'stringstream' base-class with our own stream with a specialized
46 /// streambuf which allows to efficiently access the contents as a C string.
47 buffer_ = this->str();
48 return buffer_.c_str();
51 prefix_ int senf::SystemException::errorNumber()
57 prefix_ char const * senf::SystemException::description()
60 return std::strerror(code_);
63 prefix_ bool senf::SystemException::anyOf(int c0, int c1, int c2, int c3, int c4, int c5,
64 int c6, int c7, int c8, int c9)
67 (c0 && code_ == c0) ||
68 (c1 && code_ == c1) ||
69 (c2 && code_ == c2) ||
70 (c3 && code_ == c3) ||
71 (c4 && code_ == c4) ||
72 (c5 && code_ == c5) ||
73 (c6 && code_ == c6) ||
74 (c7 && code_ == c7) ||
75 (c8 && code_ == c8) ||
79 prefix_ senf::SystemException::~SystemException()
83 prefix_ void senf::throwErrno()
85 throwErrno("", errno);
88 prefix_ void senf::throwErrno(std::string const & where)
90 throwErrno(where, errno);
93 prefix_ void senf::throwErrno(int code)
98 ///////////////////////////////cci.e///////////////////////////////////////
105 // c-file-style: "senf"
106 // indent-tabs-mode: nil
107 // ispell-local-dictionary: "american"
108 // compile-command: "scons -u test"
109 // comment-column: 40