LuaD



struct  LuaTable;

Represents a Lua table.


LuaObject  object;

LuaTable sub-types luad.base.LuaObject through this reference.


@trusted T  get(T, U...)(U args);

Lookup a value in this table or in a sub-table of this table.

Parameters
T type of value
U args list of keys, where all keys but the last one should result in a table
Returns
t[k] where t is the table for the second-to-last parameter, and k is the last parameter
Examples
auto execute = lua.get!LuaFunction("os", "execute");
execute(`echo hello, world!`);

@trusted bool  readString(T)(T key, scope void delegate(in char[] str) dg);

Read a string value in this table without making a copy of the string. The read string is passed to dg, and should not be escaped. If the value for key is not a string, dg is not called.

Parameters
T key lookup key
void delegate(in char[] str) dg delegate to receive string
Returns
true if the value for key was a string and passed to dg, false otherwise
Examples
t[2] = "two";
t.readString(2, str => assert(str == "two"));

LuaObject  opIndex(T...)(T args);

Same as calling get!LuaObject with the same arguments.

Examples
auto luapath = lua["package", "path"];
writefln("LUA_PATH:\n%s", luapath);
See Also
LuaTable.get

@trusted void  set(T, U)(T key, U value);

Set a key-value pair in this table.

Parameters
T key key to set
U value value for key

@trusted void  opIndexAssign(T, U...)(T value, U args);

Set a key-value pair this table or in a sub-table of this table.

Parameters
T value value to set
U args list of keys, where all keys but the last one should result in a table
Returns
t[k] = value, where t is the table for the second-to-last parameter in args, and k is the last parameter in args
Examples
lua["string", "empty"] = (in char[] s){ return s.length == 0; };
lua.doString(`assert(string.empty(""))`);

@trusted T  toStruct(T)() if (is(T == struct));

Create struct of type T and fill its members with fields from this table.

Struct fields that are not present in this table are left at their default value.

Parameters
T any struct type
Returns
Newly created struct

@trusted void  copyTo(T)(ref T s) if (is(T == struct));

Fill a struct's members with fields from this table.

Parameters
T s struct to fill

@trusted void  setMetaTable(ref LuaTable meta);

Set the metatable for this table.

Parameters
LuaTable meta new metatable

@trusted LuaTable  getMetaTable();

Get the metatable for this table.

Returns
A reference to the metatable for this table. The reference is nil if this table has no metatable.

@trusted size_t  length();

Get the array  length of the table.


@trusted int  opApply(T)(int delegate(ref T value) dg);

Iterate over the values in this table.


@trusted int  opApply(T, U)(int delegate(ref U key, ref T value) dg);

Iterate over the key-value pairs in this table.