Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Exception.cci
1 // $Id$
2 //
3 // Copyright (C) 2006 Stefan Bund <g0dil@senf.berlios.de>
4 //
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.
9 //
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.
14 //
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.
19
20 /** \file
21     \brief Exception inline non-template implementation */
22
23 // Custom includes
24 #include <errno.h>
25 #include <cstring>
26
27 #define prefix_ inline
28 ///////////////////////////////cci.p///////////////////////////////////////
29
30 ///////////////////////////////////////////////////////////////////////////
31 // senf::ExceptionMixin
32
33 prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description)
34     : message_(description)
35 {
36 #ifdef SENF_DEBUG
37     addBacktrace();
38 #endif
39 }
40
41 prefix_ std::string const & senf::ExceptionMixin::message()
42     const
43 {
44     return message_;
45 }
46
47 prefix_ void senf::ExceptionMixin::append(std::string text)
48 {
49     message_ += text;
50 }
51
52 ///////////////////////////////////////////////////////////////////////////
53 // senf::Exception
54
55 prefix_ senf::Exception::Exception(std::string const & description)
56     : ExceptionMixin(description)
57 {}
58
59 ///////////////////////////////////////////////////////////////////////////
60 // senf::SystemException
61
62 prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND)
63 {
64     init(descr, errno _SENF_EXC_DEBUG_ARGS_P);
65 }
66
67 prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND)
68 {
69     init("", code _SENF_EXC_DEBUG_ARGS_P);
70 }
71
72 prefix_ senf::SystemException::SystemException(std::string const & descr, int code 
73                                                _SENF_EXC_DEBUG_ARGS_ND)
74 {
75     init(descr, code _SENF_EXC_DEBUG_ARGS_P);
76 }
77
78 prefix_ int senf::SystemException::errorNumber()
79     const
80 {
81     return code_;
82 }
83
84 prefix_ char const * senf::SystemException::errorString()
85     const
86 {
87     return std::strerror(code_);
88 }
89
90 prefix_ bool senf::SystemException::anyOf(int c0, int c1, int c2, int c3, int c4, int c5,
91                                           int c6, int c7, int c8, int c9)
92 {
93     return 
94         (c0 && code_ == c0) ||
95         (c1 && code_ == c1) ||
96         (c2 && code_ == c2) ||
97         (c3 && code_ == c3) ||
98         (c4 && code_ == c4) ||
99         (c5 && code_ == c5) ||
100         (c6 && code_ == c6) ||
101         (c7 && code_ == c7) ||
102         (c8 && code_ == c8) ||
103         (c9 && code_ == c9);
104 }
105
106 prefix_  senf::SystemException::~SystemException()
107     throw()
108 {}
109
110 ///////////////////////////////cci.e///////////////////////////////////////
111 #undef prefix_
112
113 \f
114 // Local Variables:
115 // mode: c++
116 // fill-column: 100
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // comment-column: 40
122 // End: