Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
l_metadata.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013-8 celeron55, Perttu Ahola <celeron55@gmail.com>
4// Copyright (C) 2017-8 rubenwardy <rw@rubenwardy.com>
5
6#pragma once
7
9#include "lua_api/l_base.h"
10
11class IMetadata;
12
13/*
14 NodeMetaRef
15*/
16
17class MetaDataRef : public ModApiBase
18{
19public:
20 virtual ~MetaDataRef() = default;
21
22 static MetaDataRef *checkAnyMetadata(lua_State *L, int narg);
23
24protected:
25 virtual void reportMetadataChange(const std::string *name = nullptr) {}
26 virtual IMetadata *getmeta(bool auto_create) = 0;
27 virtual void clearMeta() = 0;
28
29 virtual void handleToTable(lua_State *L, IMetadata *meta);
30 virtual bool handleFromTable(lua_State *L, int table, IMetadata *meta);
31
32 static void registerMetadataClass(lua_State *L, const char *name, const luaL_Reg *methods);
33
34 // Exported functions
35
36 static int gc_object(lua_State *L);
37
38 // contains(self, name)
39 static int l_contains(lua_State *L);
40
41 // get(self, name)
42 static int l_get(lua_State *L);
43
44 // get_string(self, name)
45 static int l_get_string(lua_State *L);
46
47 // set_string(self, name, var)
48 static int l_set_string(lua_State *L);
49
50 // get_int(self, name)
51 static int l_get_int(lua_State *L);
52
53 // set_int(self, name, var)
54 static int l_set_int(lua_State *L);
55
56 // get_float(self, name)
57 static int l_get_float(lua_State *L);
58
59 // set_float(self, name, var)
60 static int l_set_float(lua_State *L);
61
62 // get_keys(self)
63 static int l_get_keys(lua_State *L);
64
65 // to_table(self)
66 static int l_to_table(lua_State *L);
67
68 // from_table(self, table)
69 static int l_from_table(lua_State *L);
70
71 // equals(self, other)
72 static int l_equals(lua_State *L);
73};
Definition metadata.h:14
Definition l_metadata.h:18
static void registerMetadataClass(lua_State *L, const char *name, const luaL_Reg *methods)
Definition l_metadata.cpp:316
static int l_from_table(lua_State *L)
Definition l_metadata.cpp:237
virtual void handleToTable(lua_State *L, IMetadata *meta)
Definition l_metadata.cpp:265
static int l_get(lua_State *L)
Definition l_metadata.cpp:56
static MetaDataRef * checkAnyMetadata(lua_State *L, int narg)
Definition l_metadata.cpp:14
static int l_get_int(lua_State *L)
Definition l_metadata.cpp:118
virtual bool handleFromTable(lua_State *L, int table, IMetadata *meta)
Definition l_metadata.cpp:282
static int gc_object(lua_State *L)
Definition l_metadata.cpp:30
static int l_set_int(lua_State *L)
Definition l_metadata.cpp:138
static int l_get_float(lua_State *L)
Definition l_metadata.cpp:154
virtual ~MetaDataRef()=default
virtual IMetadata * getmeta(bool auto_create)=0
static int l_equals(lua_State *L)
Definition l_metadata.cpp:303
static int l_get_keys(lua_State *L)
Definition l_metadata.cpp:193
static int l_get_string(lua_State *L)
Definition l_metadata.cpp:77
virtual void clearMeta()=0
static int l_set_float(lua_State *L)
Definition l_metadata.cpp:176
static int l_to_table(lua_State *L)
Definition l_metadata.cpp:218
static int l_contains(lua_State *L)
Definition l_metadata.cpp:40
static int l_set_string(lua_State *L)
Definition l_metadata.cpp:97
virtual void reportMetadataChange(const std::string *name=nullptr)
Definition l_metadata.h:25
Definition l_base.h:28
static const struct table_key table[]
Definition keycode.cpp:33