Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
helper.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2018 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
4
5#pragma once
6
7#include <string_view>
8
9extern "C" {
10#include <lua.h>
11}
12
14{
15protected:
24 template <typename T>
25 static T readParam(lua_State *L, int index);
26
36 template <typename T>
37 static inline T readParam(lua_State *L, int index, const T &default_value)
38 {
39 return lua_isnoneornil(L, index) ? default_value : readParam<T>(L, index);
40 }
41};
42
43// (only declared for documentation purposes:)
44
55template <>
56std::string_view LuaHelper::readParam(lua_State *L, int index);
Definition helper.h:14
static T readParam(lua_State *L, int index)
Read a value using a template type T from Lua state L at index.
static T readParam(lua_State *L, int index, const T &default_value)
Read a value using a template type T from Lua state L at index.
Definition helper.h:37