-
Notifications
You must be signed in to change notification settings - Fork 184
/
ErrorHandling.hpp
executable file
·69 lines (52 loc) · 1.48 KB
/
ErrorHandling.hpp
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
//
// ErrorHandling.hpp
// CommonLibrary
//
// Created by Andreas Schacherbauer on 23.02.18.
// Copyright © 2018 Wikitude. All rights reserved.
//
#ifndef ErrorHandling_hpp
#define ErrorHandling_hpp
#ifdef __cplusplus
#include "CompilerAttributes.hpp"
#include "Error.hpp"
namespace wikitude::sdk {
struct WT_EXPORT_API CallStatus {
public:
static CallStatus Success() {
return {true, Error::NoError()};
}
public:
CallStatus(bool success_, sdk::Error error_)
:
_success(success_),
_error(error_)
{ /* Intentionally Left Blank */ }
explicit operator bool () const {
return _success;
}
bool _success;
sdk::Error _error;
};
template <typename T>
struct WT_EXPORT_API CallValue {
public:
static CallValue<T> SuccessCallValue(T value_) {
return {value_, {true, Error::NoError()}};
}
public:
CallValue<T>(T value_, CallStatus status_)
:
_value(value_),
_status(status_)
{ /* Intentionally Left Blank */ }
explicit operator bool () const {
return _status._success;
}
public:
T _value;
CallStatus _status;
};
}
#endif /* __cplusplus */
#endif /* ErrorHandling_hpp */