-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherrors.h
executable file
·75 lines (60 loc) · 1.68 KB
/
errors.h
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
69
70
71
72
73
74
75
#ifndef _ERRORS_H
#define _ERRORS_H
#include <iostream>
#include <string>
using namespace std;
class Argument_error {
string errmsg;
public:
friend ostream& operator << (ostream& os, const Argument_error& ae) {
os << "Argument error: " << ae.errmsg;
return os;
}
explicit Argument_error(const char * str) : errmsg(str) {}
};
class File_open_error {
string filename;
public:
friend ostream& operator << (ostream& os, const File_open_error& fe) {
os << "Error opening " << fe.filename;
return os;
}
explicit File_open_error(const string& name) : filename(name) {}
};
class Parse_error {
public:
virtual void print_self(ostream& os) const {
os << "unspecified.";
}
friend ostream& operator << (ostream& os, const Parse_error& pe) {
os << "Parse error: ";
pe.print_self(os);
return os;
}
virtual ~Parse_error() {}
};
class Parse_error_str : public Parse_error {
string str;
public:
virtual void print_self(ostream& os) const {
os << str;
}
explicit Parse_error_str(string s) : str(s) {}
};
class Size_mismatch : public Parse_error {
const unsigned long real_size, read_size;
public:
virtual void print_self(ostream& os) const {
os << "expected " << real_size << " bits, read " << read_size;
}
Size_mismatch(unsigned long real_s, unsigned long read_s) : real_size(real_s), read_size(read_s) {}
};
class Invalid_id : public Parse_error {
const int id;
public:
virtual void print_self(ostream& os) const {
os << "invalid codebook id " << id << ", try --inline-codebooks";
}
explicit Invalid_id(int i) : id(i) {}
};
#endif