aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/luaengine.h
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2024-04-12 14:40:21 +0200
committerMarcus Tillmanns <[email protected]>2024-04-30 04:48:23 +0000
commit0543085a64b40e8ffffbc65feab6e7200ac7439d (patch)
tree1dbe0e4ccbc54b1c7268c9e7dc86761db464502e /src/plugins/lua/luaengine.h
parentcaf31c4fe95acd48c3e497a29e1bbce985b0c080 (diff)
Lua: Add luatemplates
Change-Id: Icc9e7505156eb8749da64e1f4022f27a57018a67 Reviewed-by: Alessandro Portale <[email protected]>
Diffstat (limited to 'src/plugins/lua/luaengine.h')
-rw-r--r--src/plugins/lua/luaengine.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/lua/luaengine.h b/src/plugins/lua/luaengine.h
index b0e34eb4169..43a4387bef6 100644
--- a/src/plugins/lua/luaengine.h
+++ b/src/plugins/lua/luaengine.h
@@ -55,6 +55,17 @@ public:
static sol::table toTable(const sol::state_view &lua, const QJsonValue &v);
static QJsonValue toJson(const sol::table &t);
+ template<class T>
+ static void checkKey(const sol::table &table, const QString &key)
+ {
+ if (table[key].template is<T>())
+ return;
+ if (!table[key].valid())
+ throw sol::error("Expected " + key.toStdString() + " to be defined");
+ throw sol::error(
+ "Expected " + key.toStdString() + " to be of type " + sol::detail::demangle<T>());
+ }
+
static QStringList variadicToStringList(const sol::variadic_args &vargs);
template<typename R, typename... Args>