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
76
77
78
79
80
81
82
83
|
/*********************************************************************************************************************
* Copyright 2013-2014 Tobii Technology AB. All rights reserved.
* APIException.hpp
*********************************************************************************************************************/
#if !defined(__TOBII_TX_CLIENT_CPPBINDINGS_APIEXCEPTION__HPP__)
#define __TOBII_TX_CLIENT_CPPBINDINGS_APIEXCEPTION__HPP__
/*********************************************************************************************************************/
TX_NAMESPACE_BEGIN
/*********************************************************************************************************************/
class APIException
{
public:
APIException(TX_RESULT result, const std::string& message = "")
: _result(result), _message(message)
{ }
TX_RESULT GetResult() const
{
return _result;
}
std::string GetMessage() const
{
return _message;
}
private:
TX_RESULT _result;
std::string _message;
};
/*********************************************************************************************************************/
inline bool TX_VALIDATE(TX_RESULT result)
{
if(result == TX_RESULT_OK)
return true;
throw EyeX::APIException(result, "Error");
}
/*********************************************************************************************************************/
inline bool TX_VALIDATE(TX_RESULT result, TX_RESULT falseResult)
{
if(result == falseResult)
return false;
return TX_VALIDATE(result);
}
/*********************************************************************************************************************/
inline bool TX_VALIDATE(TX_RESULT result, TX_RESULT falseResult1, TX_RESULT falseResult2)
{
if(result == falseResult2)
return false;
return TX_VALIDATE(result, falseResult1);
}
template <typename THandle1, typename THandle2>
inline std::string GetString(TX_RESULT (*pFn)(THandle1, TX_STRING, TX_SIZE*), THandle2 handle, TX_SIZE estimatedLength = 0)
{
std::string str;
TX_VALIDATE(GetString(&str, pFn, handle, estimatedLength));
return str;
}
/*********************************************************************************************************************/
TX_NAMESPACE_END
/*********************************************************************************************************************/
#endif // !defined(__TOBII_TX_CLIENT_CPPBINDINGS_APIEXCEPTION__HPP__)
/*********************************************************************************************************************/
|