In C++, I have a map<string, string>
, containing an unknown number of entries. How can I pass this to a Lua function, so that the Lua function can use the data as a table?
相关问题
- Sorting 3 numbers without branching [closed]
- How to get the return code of a shell script in lu
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- how to split a list into a given number of sub-lis
相关文章
- JSP String formatting Truncate
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
if you want a real lua table:
with the right types for your map substituted in..
A couple options...
Copy the map into a new Lua table, and pass the Lua table.
Create a proxy table that directs reads and writes through a metatable's
__index
and__newindex
metamethodsThe drawback to (1) is all the copying, of course.
The drawback to (2) is that
pairs()
won't work on the proxy tableA discussion of fixes to Lua for generalized
pairs
is in the wiki and this mailing list thread. Generalizedpairs
is expected for Lua 5.2