Arbutils/CInterface/Core.hpp

29 lines
1.3 KiB
C++

#ifndef ARBUTILS_CORE_HPP
#define ARBUTILS_CORE_HPP
#include <cstring>
#include <exception>
#include <string>
#define export extern "C"
#define ArbutilsException 3;
class ExceptionHandler {
static std::string _ArbutilsLastException;
public:
static void SetLastException(const std::exception& e) { _ArbutilsLastException = std::string(e.what()); }
static const char* GetLastException() { return _ArbutilsLastException.c_str(); }
};
#define Try(data) \
try { \
data; \
return 0; \
} catch (const std::exception& e) { \
ExceptionHandler::SetLastException(e); \
return ArbutilsException; \
}
#endif // ARBUTILS_CORE_HPP