~ubuntu-branches/ubuntu/gutsy/poco/gutsy

« back to all changes in this revision

Viewing changes to CppUnit/include/CppUnit/CppUnitException.h

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2007-04-27 18:33:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070427183348-xgnpct0qd6a2ip34
Tags: upstream-1.2.9
ImportĀ upstreamĀ versionĀ 1.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// CppUnitException.h
 
3
//
 
4
// $Id: //poco/1.2/CppUnit/include/CppUnit/CppUnitException.h#1 $
 
5
//
 
6
 
 
7
 
 
8
#ifndef CppUnit_CppUnitException_INCLUDED
 
9
#define CppUnit_CppUnitException_INCLUDED
 
10
 
 
11
 
 
12
#include "CppUnit/CppUnit.h"
 
13
#include <exception>
 
14
#include <string>
 
15
 
 
16
 
 
17
namespace CppUnit {
 
18
 
 
19
 
 
20
class CppUnit_API CppUnitException: public std::exception
 
21
        /// CppUnitException is an exception that serves
 
22
        /// descriptive strings through its what() method
 
23
{
 
24
public:
 
25
        CppUnitException(const std::string& message = "", 
 
26
                         long lineNumber = CPPUNIT_UNKNOWNLINENUMBER, 
 
27
                         const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
 
28
        CppUnitException(const std::string& message,
 
29
                         long lineNumber,
 
30
                         long data1lineNumber,
 
31
                         const std::string& fileName);
 
32
        CppUnitException(const std::string& message,
 
33
                         long lineNumber,
 
34
                         long data1lineNumber,
 
35
                         long data2lineNumber,
 
36
                         const std::string& fileName);
 
37
        CppUnitException(const CppUnitException& other);
 
38
        virtual ~CppUnitException() throw();
 
39
 
 
40
        CppUnitException& operator = (const CppUnitException& other);
 
41
 
 
42
        const char* what() const throw ();
 
43
 
 
44
        long lineNumber() const;
 
45
        long data1LineNumber() const;
 
46
        long data2LineNumber() const;
 
47
        const std::string& fileName() const;
 
48
 
 
49
        static const std::string CPPUNIT_UNKNOWNFILENAME;
 
50
        static const int CPPUNIT_UNKNOWNLINENUMBER;
 
51
 
 
52
private:
 
53
        std::string _message;
 
54
        long        _lineNumber;
 
55
        long        _data1lineNumber;
 
56
        long        _data2lineNumber;
 
57
        std::string _fileName;
 
58
};
 
59
 
 
60
 
 
61
inline CppUnitException::CppUnitException(const CppUnitException& other): exception (other)
 
62
{
 
63
    _message         = other._message;
 
64
    _lineNumber      = other._lineNumber;
 
65
    _data1lineNumber = other._data1lineNumber;
 
66
    _data2lineNumber = other._data2lineNumber;
 
67
    _fileName        = other._fileName;
 
68
}
 
69
 
 
70
 
 
71
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName)
 
72
{
 
73
}
 
74
 
 
75
 
 
76
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName)
 
77
{
 
78
}
 
79
 
 
80
 
 
81
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(data2lineNumber), _fileName(fileName)
 
82
{
 
83
}
 
84
 
 
85
 
 
86
inline CppUnitException::~CppUnitException () throw()
 
87
{
 
88
}
 
89
 
 
90
 
 
91
inline CppUnitException& CppUnitException::operator = (const CppUnitException& other)
 
92
{
 
93
        exception::operator= (other);
 
94
 
 
95
    if (&other != this)
 
96
    {
 
97
        _message    = other._message;
 
98
        _lineNumber = other._lineNumber;
 
99
        _data1lineNumber = other._data1lineNumber;
 
100
        _data2lineNumber = other._data2lineNumber;
 
101
        _fileName   = other._fileName;
 
102
    }
 
103
    return *this;
 
104
}
 
105
 
 
106
 
 
107
inline const char* CppUnitException::what() const throw ()
 
108
{
 
109
        return _message.c_str();
 
110
}
 
111
 
 
112
 
 
113
inline long CppUnitException::lineNumber() const
 
114
{
 
115
        return _lineNumber; 
 
116
}
 
117
 
 
118
 
 
119
inline long CppUnitException::data1LineNumber() const
 
120
{
 
121
        return _data1lineNumber; 
 
122
}
 
123
 
 
124
 
 
125
inline long CppUnitException::data2LineNumber() const
 
126
{
 
127
        return _data2lineNumber; 
 
128
}
 
129
 
 
130
 
 
131
// The file in which the error occurred
 
132
inline const std::string& CppUnitException::fileName() const
 
133
{
 
134
        return _fileName; 
 
135
}
 
136
 
 
137
 
 
138
} // namespace CppUnit
 
139
 
 
140
 
 
141
#endif // CppUnit_CppUnitException_INCLUDED