diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-22 18:15:13 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-22 18:15:13 +0200 |
commit | d468b693d79ddb416c45669e5ca8400cbdc34e85 (patch) | |
tree | e31876c81dae1e3f8359c129f348ed3511342470 /src/compat.h | |
parent | 9617dd452e529af3a12b14a98cd2edbfd93ea712 (diff) | |
download | lanes-d468b693d79ddb416c45669e5ca8400cbdc34e85.tar.gz lanes-d468b693d79ddb416c45669e5ca8400cbdc34e85.tar.bz2 lanes-d468b693d79ddb416c45669e5ca8400cbdc34e85.zip |
DEBUGSPEW fprintf(stderr) → std::cerr
Diffstat (limited to 'src/compat.h')
-rw-r--r-- | src/compat.h | 9 |
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 |