summaryrefslogtreecommitdiffhomepage
path: root/Tobii EyeX/include/eyex-cpp/APIException.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-16 11:19:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-09 10:28:01 +0200
commitbe2926499af2e372c313d965533be3a7ee0dcf4d (patch)
tree34501ef650da4a2990912bd0b38ed7135696c164 /Tobii EyeX/include/eyex-cpp/APIException.hpp
parent6eb99f06be3ead3c898b400d7b9072583c7addf0 (diff)
add tobii eyex sdk
Diffstat (limited to 'Tobii EyeX/include/eyex-cpp/APIException.hpp')
-rwxr-xr-xTobii EyeX/include/eyex-cpp/APIException.hpp83
1 files changed, 83 insertions, 0 deletions
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 <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__)
+
+/*********************************************************************************************************************/