#ifndef PKMNLIB_CORE_HPP #define PKMNLIB_CORE_HPP #include #include #include #define export extern "C" [[maybe_unused]] #define PkmnLibException 4 class ExceptionHandler { static std::string _pkmnLibLastException; public: static void SetLastException(const std::exception& e) { _pkmnLibLastException = std::string(e.what()); } static const char* GetLastException() { return _pkmnLibLastException.c_str(); } }; #define Try(data) \ try { \ data; \ return 0; \ } catch (const std::exception& e) { \ ExceptionHandler::SetLastException(e); \ return PkmnLibException; \ } #define SIMPLE_GET_FUNC(type, name, returnType) \ export returnType PkmnLib_##type##_##name(const type* p) { return p->name(); } #define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \ export returnType PkmnLib_##type##_##name(const type* p) { return p->name().GetRaw(); } #define DESTRUCTOR(type) \ export void PkmnLib_##type##_Destruct(const type* p) { delete p; } #endif // PKMNLIB_CORE_HPP