-
Notifications
You must be signed in to change notification settings - Fork 5
/
Status.h
62 lines (39 loc) · 1.36 KB
/
Status.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
#ifndef STATUS_H
#define STATUS_H
#include <cstdint>
//
// All contents adapted from Arrow's own Status class
//
// Return the given status if it is not OK.
#define DB_RETURN_NOT_OK(s) \
do { \
::db::Status _s = (s); \
if (!_s.ok()) { \
return _s; \
} \
} while (false)
namespace db {
enum class StatusCode : std::uint8_t {
OK = 0,
NotFound = 1,
InternalError = 2,
OutOfMemory = 3,
UnevenArgLists = 4,
InvalidColumn = 5
};
class Status {
public:
Status(StatusCode code) : _code(code) {}
static Status OK() { return Status(StatusCode::OK); }
bool ok() const { return (_code == StatusCode::OK); }
bool notFound() const { return (_code == StatusCode::NotFound); }
bool internalError() const { return (_code == StatusCode::InternalError); }
bool outOfMemory() const { return (_code == StatusCode::OutOfMemory); }
bool unevenArgLists() const { return (_code == StatusCode::UnevenArgLists); }
bool invalidColumn() const { return (_code == StatusCode::InvalidColumn); }
StatusCode code() const { return _code; }
private:
StatusCode _code;
};
};
#endif //STATUS_H