aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compat.h b/src/compat.h
index 139e606..b971a76 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -264,6 +264,16 @@ LuaType luaG_getmodule(lua_State* L_, std::string_view const& name_);
264 return std::string_view{ _str, _len }; 264 return std::string_view{ _str, _len };
265} 265}
266 266
267[[nodiscard]] inline std::string_view luaL_optstringview(lua_State* L_, int idx_, std::string_view const& default_)
268{
269 if (lua_isnoneornil(L_, idx_)) {
270 return default_;
271 }
272 size_t _len{ 0 };
273 char const* _str{ luaL_optlstring(L_, idx_, default_.data(), &_len) };
274 return std::string_view{ _str, _len };
275}
276
267[[nodiscard]] inline std::string_view lua_pushstringview(lua_State* L_, std::string_view const& str_) 277[[nodiscard]] inline std::string_view lua_pushstringview(lua_State* L_, std::string_view const& str_)
268{ 278{
269#if LUA_VERSION_NUM == 501 279#if LUA_VERSION_NUM == 501