Newer
Older
/*!
** Constructor
**
** @param i error code
** @param s error message
*/
Error::Error(int i, const string s)
{
val_ = i;
msg_ << s;
}
/*!
** Constructor by copy
**
** @param e
*/
Error::Error(const Error &e)
{
val_ = e.val_;
msg_ << e.msg_.str();
}
/*!
** Print and error msg on std err
**
*/
void Error::print() const
{
if (msg_.str() != "")
std::cerr << msg_.str() << "." << std::endl;
}
/*!
** @return a copy of message description
*/
string Error::message() const
{
return msg_.str();
}
int Error::code() const
{
return val_;
}
Error &Error::operator=(const Error &rhs)
{
val_ = rhs.val_;
msg_.str("");
msg_ << rhs.msg_.str();
return *this;
}
/*!
** Print error message to @param o stream
*/
ostream &operator<<(ostream &o, const Error &e)
{
o << e.msg_.str();
return o;
}
/*!
** Concatenate @param val to errror message
*/
Error &operator<<(Error &e, int val)
{
e.msg_ << val;
return e;
}
/*!
** Concatenate @param s to errror message
*/
Error &operator<<(Error &e, const string &s)
{
e.msg_ << s;
return e;
}
/*!
** Concatenate @param s before error message
*/