Exception.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Exception.h"
00013 using namespace OpenCAL::Exceptions;
00014
00015 #include <sstream>
00016 using std::ostringstream;
00017
00018 using namespace std;
00019
00020
00021
00022
00023
00024
00025 Exception::Exception(const string &file, int line)
00026 : m_type("OpenCAL Exception"), m_message(""), m_file(file), m_line(line)
00027 {
00028 }
00029
00030 Exception::Exception(const string &message, const string &file, int line)
00031 : m_type("OpenCAL Exception"), m_message(message), m_file(file), m_line(line)
00032 {
00033 }
00034
00035 Exception::~Exception()
00036 {
00037 }
00038
00039
00040
00041
00042
00043
00044 string Exception::toString() const
00045 {
00046 ostringstream result;
00047
00048 result << m_type;
00049 if(m_line > 0)
00050 result << " at line " << m_line;
00051 if(m_file.length() > 0)
00052 result << " in file " << m_file;
00053 if(m_message.length() > 0)
00054 result << ": " << m_message;
00055
00056 return result.str();
00057 }
00058
00059 void Exception::print() const
00060 {
00061 cout << toString() << endl;
00062 }
00063
00064
00065 ostream &OpenCAL::Exceptions::operator<<(ostream &stream, const Exception &e)
00066 {
00067 stream << e.toString();
00068 return stream;
00069 }
Generated on Sun Aug 15 19:19:22 2004 for OpenCAL: Open Computer Animation Library by
1.3.8