aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compat.h b/src/compat.h
index f097fb6..e080749 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -247,6 +247,8 @@ LuaType luaG_getmodule(lua_State* L_, char const* name_);
247 247
248// ################################################################################################# 248// #################################################################################################
249 249
250#define STRINGVIEW_FMT "%.*s"
251
250// a replacement of lua_tolstring 252// a replacement of lua_tolstring
251[[nodiscard]] inline std::string_view lua_tostringview(lua_State* L_, int idx_) 253[[nodiscard]] inline std::string_view lua_tostringview(lua_State* L_, int idx_)
252{ 254{
@@ -255,6 +257,13 @@ LuaType luaG_getmodule(lua_State* L_, char const* name_);
255 return std::string_view{ _str, _len }; 257 return std::string_view{ _str, _len };
256} 258}
257 259
260[[nodiscard]] inline std::string_view luaL_checkstringview(lua_State* L_, int idx_)
261{
262 size_t _len{ 0 };
263 char const* _str{ luaL_checklstring(L_, idx_, &_len) };
264 return std::string_view{ _str, _len };
265}
266
258[[nodiscard]] inline std::string_view lua_pushstringview(lua_State* L_, std::string_view const& str_) 267[[nodiscard]] inline std::string_view lua_pushstringview(lua_State* L_, std::string_view const& str_)
259{ 268{
260#if LUA_VERSION_NUM == 501 269#if LUA_VERSION_NUM == 501