Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
#include "sudoku.hh"
Error::Error(int v)
{
val_ = v;
}
Error::Error(const string s, int i)
{
val_ = i;
msg_ << s;
}
Error::Error(const Error &e)
{
val_ = e.val_;
msg_ << e.msg_.str();
}
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;
}