/[escript]/branches/windows_from_1431_trunk/esysUtils/src/EsysException.h
ViewVC logotype

Contents of /branches/windows_from_1431_trunk/esysUtils/src/EsysException.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1445 - (show annotations)
Thu Feb 28 09:55:31 2008 UTC (13 years, 7 months ago) by trankine
File MIME type: text/plain
File size: 4437 byte(s)
get rid of a throw() qualifier.
1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #ifndef ESYSEXCEPTION_H
17 #define ESYSEXCEPTION_H
18 #include "system_dep.h"
19
20 #include <string>
21 #include <exception>
22
23 namespace esysUtils
24 {
25 /**
26 \page esys_exception Esys Exceptions
27 A base class for exception classes used within Esys system.
28
29 \version 1.0.0
30
31 \section class_desc Class Description:
32 A base class for exception classes used within Esys system.
33
34 \section class_limits Class Limitations:
35 None
36
37 \section class_conds Class Conditions of Use:
38 None
39
40 \section throws Throws:
41 None
42
43 */
44 class EsysException:public std::exception {
45
46 public:
47 /**
48 \brief
49 Default Constructor. Creates an exception with no message.
50 */
51 EsysException();
52
53 /**
54 * \brief
55 Constructor which creates a EsysException with the given message
56
57 @param exceptionReason Input - Exception message.
58 */
59 EsysException(const std::string &exceptionReason);
60
61 /**
62 * \brief
63 Constructor which creates a EsysException with the given message
64
65 @param cStr - Exception message.
66 */
67 EsysException( const char *cStr );
68
69 /**
70 * \brief
71 Copy constructor
72
73 @param inException Input - EsysException
74 */
75 EsysException(const EsysException &inException);
76
77 /// Destructor
78 virtual ~EsysException();
79
80 /**
81 \brief
82 Assignment operator.
83
84 @param inException Input - Exception to be copied.
85 */
86 EsysException &operator=(const EsysException &inException);
87
88 /**
89 \brief
90 Return the exception message in the form
91 &lt;Exception Name&gt;: &lt;Exception Message&gt;
92
93 @return the exception message.
94 */
95 const std::string & toString() const;
96
97 /**
98 \brief
99 Return the name of the exception. This is expected to be overloaded
100 in derived classes with the derived class name.
101
102 @return the name of the exception.
103 */
104 virtual const std::string & exceptionName() const;
105
106 /**
107 \brief
108 Return a reference to the string that contains the exception reason.
109
110 @return the string for the exception reason.
111 */
112 const std::string& reason() const;
113
114 /**
115 \brief
116 set the string for the reason for the exception.
117 This allows ousiders to modify m_reason, but the practice is discouraged.
118 If string insertions are required, use string methods.
119 */
120 void setReason(const std::string &new_reason);
121
122 /**
123 \brief
124 Return a description of the exception in the same format as the toString
125 method.
126
127 @return a description of the exception.
128 */
129 virtual const char* what() const;
130
131
132 /**
133 \brief
134 update m_exceptionMessage after a reason update.
135 **/
136 void updateMessage();
137
138
139 private:
140 //
141 // the exception reason
142 std::string m_reason;
143
144 //
145 // the full exception message
146 std::string m_exceptionMessage;
147
148 //
149 // the exception name is immutable and class-wide.
150 // Inheritor note; you need one of these too.
151 // and an overloaded exceptionName() in your .cpp implementation file.
152 static const std::string exceptionNameValue;
153
154 };
155
156 /**
157 \brief
158 Stream insertion (print) operator for EsysExceptions
159
160 @param output Input - Output stream.
161 @param inException Input - The exception to be inserted into the output
162 stream.
163 */
164 std::ostream &operator<<(std::ostream &output, EsysException &inException);
165
166
167 ////////////////////////////////////////////////////////////////////
168
169 inline
170 const std::string & EsysException::reason() const
171 {
172 return m_reason;
173 }
174
175 // return the message as a std::string
176 inline
177 const std::string & EsysException::toString() const
178 {
179 return m_exceptionMessage;
180 }
181
182 inline
183 void EsysException::setReason(const std::string &new_reason)
184 {
185 m_reason = new_reason;
186 updateMessage();
187 }
188
189 inline
190 const char* EsysException::what() const
191 {
192 return m_exceptionMessage.c_str();
193 }
194
195
196
197 inline
198 void EsysException::updateMessage()
199 {
200 m_exceptionMessage = exceptionName() + ": " + m_reason;
201 }
202
203 }
204
205 #endif

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26