implement API to save lists in configs file and terminal history

This commit is contained in:
Eduardo Bart
2012-01-15 13:13:22 -02:00
parent a238111c07
commit 9ec40f016d
20 changed files with 228 additions and 58 deletions

View File

@@ -125,6 +125,9 @@ luavalue_cast(int index, std::function<Ret(Args...)>& func);
template<typename T>
void push_luavalue(const std::vector<T>& vec);
template<typename T>
bool luavalue_cast(int index, std::vector<T>& vec);
// deque
template<class T>
void push_luavalue(const std::deque<T>& vec);
@@ -249,6 +252,22 @@ void push_luavalue(const std::vector<T>& vec) {
}
}
template<typename T>
bool luavalue_cast(int index, std::vector<T>& vec)
{
if(g_lua.isTable(index)) {
g_lua.pushNil();
while(g_lua.next(index < 0 ? index-1 : index)) {
T value;
if(luavalue_cast(-1, value))
vec.push_back(value);
g_lua.pop();
}
return true;
}
return false;
}
template<typename T>
void push_luavalue(const std::deque<T>& vec) {
g_lua.newTable();