From be2926499af2e372c313d965533be3a7ee0dcf4d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 May 2016 11:19:10 +0200 Subject: add tobii eyex sdk --- Tobii EyeX/include/eyex-cpp/APIException.hpp | 83 ++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 Tobii EyeX/include/eyex-cpp/APIException.hpp (limited to 'Tobii EyeX/include/eyex-cpp/APIException.hpp') diff --git a/Tobii EyeX/include/eyex-cpp/APIException.hpp b/Tobii EyeX/include/eyex-cpp/APIException.hpp new file mode 100755 index 0000000..d270c04 --- /dev/null +++ b/Tobii EyeX/include/eyex-cpp/APIException.hpp @@ -0,0 +1,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 +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__) + +/*********************************************************************************************************************/ -- cgit v1.2.3