Newer
Older
/*
This file is part of SLD.
Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net>
SLD is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
SLD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SLD; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
Error::Error(int i, const string s)
{
val_ = i;
msg_ << s;
}
Error::Error(const Error &e)
{
val_ = e.val_;
msg_ << e.msg_.str();
}
void Error::print() const
{
if (msg_.str() != "")
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
}
string Error::message() const
{
return msg_.str();
}
int Error::code() const
{
return val_;
}
void Error::code(int v)
{
val_ = v;
}
Error &Error::operator=(const Error &rhs)
{
val_ = rhs.val_;
msg_.str("");
msg_ << rhs.msg_.str();
return *this;
}
ostream &operator<<(ostream &o, const Error &e)
{
o << e.msg_.str();
return o;
}
Error &operator<<(Error &e, int val)
{
e.msg_ << val;
return e;
}
Error &operator<<(Error &e, const string &s)
{
e.msg_ << s;
return e;
}
Error &operator>>(Error &e, const string &s)
{
string buf = s + e.msg_.str();
e.msg_.str("");
e.msg_ << buf;
return e;
}