/[escript]/branches/RW_WIN32/esysUtils/src/EsysException.cpp
ViewVC logotype

Contents of /branches/RW_WIN32/esysUtils/src/EsysException.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 218 - (show annotations)
Thu Nov 24 07:42:12 2005 UTC (13 years, 9 months ago) by robwdcock
File size: 2531 byte(s)
All C++/C Unit tests now build (using scons) and pass on win32
1 /*
2 ******************************************************************************
3 * *
4 * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5 * *
6 * This software is the property of ACcESS. No part of this code *
7 * may be copied in any form or by any means without the expressed written *
8 * consent of ACcESS. Copying, use or modification of this software *
9 * by any unauthorised person is illegal unless that person has a software *
10 * license agreement with ACcESS. *
11 * *
12 ******************************************************************************
13 */
14
15 #include <algorithm>
16 #include "EsysException.h"
17
18 using namespace std;
19 using namespace esysUtils;
20
21 ostream &operator<<(ostream &output, EsysException &inException){
22 output << inException.toString();
23 return output;
24 }
25
26 EsysException::EsysException():
27 exception()
28 {
29 }
30
31 EsysException::EsysException(const string &exceptionReason):
32 exception()
33 {
34 reason() << exceptionReason;
35 }
36
37 // Copy Constructor.
38 EsysException::EsysException(const EsysException &inException):
39 exception(inException)
40 {
41 *this=inException;
42 }
43
44 EsysException::EsysException( const char *cStr ):
45 exception()
46 {
47 reason() << cStr;
48 }
49
50 EsysException::~EsysException() throw()
51 {}
52
53 string EsysException::exceptionName() const
54 {
55 return "GeneralEsysException";
56 }
57 ostringstream& EsysException::reason()
58 {
59 return m_reason;
60 }
61 //
62 // Overloaded assignment operator.
63 EsysException& EsysException::operator=(const EsysException &inException) {
64 if (this != &inException) {
65 //
66 // call the base class operator=
67 // win32 refactor: parent class operator= shares pointer the result is
68 // all classes try to free the same pointer, dies on windows badly.
69 // this->exception::operator=(dynamic_cast<const exception&>(inException));
70 //
71 // copy the message buffer into this EsysException
72 m_reason << inException.m_reason.str(); // copy the message buffer into this EsysException
73 }
74 return *this;
75 }
76
77 // return the message as a string
78 string EsysException::toString() const {
79 return exceptionName() + ": " + m_reason.str();
80 }
81
82 const char* EsysException::what() const throw() {
83 //
84 m_exceptionMessage=toString();
85 return m_exceptionMessage.c_str();
86 }
87
88
89
90
91
92

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26