From 6f2b61b676a16482fdac70a58a8e875c4d68e713 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Mon, 30 Sep 2024 00:36:19 -0500 Subject: Add configuration handling. --- src/luacxx.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/luacxx.hpp (limited to 'src/luacxx.hpp') diff --git a/src/luacxx.hpp b/src/luacxx.hpp new file mode 100644 index 0000000..388f640 --- /dev/null +++ b/src/luacxx.hpp @@ -0,0 +1,47 @@ +#ifndef LUA_CXX_HPP +#define LUA_CXX_HPP + +extern "C" { +#include +} +#include +#include + +#include +#include +#include + +namespace getsuyomi { + +template +using LuaResult = fud::Result; + +static_assert(std::is_convertible_v); + +class LuaContext { +public: + LuaContext(); + ~LuaContext(); + LuaContext(const LuaContext&) = delete; + LuaContext(LuaContext&& rhs); + LuaContext& operator=(const LuaContext&) = delete; + LuaContext& operator=(LuaContext&& rhs); + + fud::FudStatus loadFile(const char* filename); + + LuaResult getGlobalInteger(const char* name); + LuaResult getGlobalString(const char* name); + LuaResult> getGlobalStringArray(const char* name); + + [[nodiscard]] constexpr bool valid() const { + return m_state != nullptr; + } + +private: + lua_State *m_state{nullptr}; +}; + +} // namespace getsuyomi + + +#endif -- cgit v1.2.3