#pragma once
#include <cstdint>
#include <exception>
#include <string>
#ifdef _WIN32
#include <time.h>
#include <windows.h>
time_t convertTmToTime(struct tm tm);
int32_t convertTimeToTm(time_t time, struct tm* out_tm);
#endif
void setLastCAPIErrorMessage(const std::string& message);
void clearLastCAPIErrorMessage();
char* takeLastCAPIErrorMessage();
char* convertToOwnedCString(const std::string& str);
#define LBUG_C_API_GUARD_BEGIN try {
#define LBUG_C_API_GUARD_END(err_ret) \
} \
catch (const std::exception& e) { \
setLastCAPIErrorMessage(e.what()); \
return err_ret; \
} \
catch (...) { \
setLastCAPIErrorMessage("unknown C++ exception in lbug C API"); \
return err_ret; \
}
#define LBUG_C_API_GUARD_END_VOID \
} \
catch (const std::exception& e) { \
setLastCAPIErrorMessage(e.what()); \
} \
catch (...) { \
setLastCAPIErrorMessage("unknown C++ exception in lbug C API"); \
}