Created
May 25, 2012 19:49
-
-
Save mrwonko/2790157 to your computer and use it in GitHub Desktop.
function pointer template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<const std::vector<std::string> (*function)(const std::string&)> luabind::object StringVectorAsTable(const std::string& argument, lua_State* L) | |
{ | |
luabind::object result = luabind::newtable(L); | |
std::vector<std::string> vec = function(argument); | |
std::vector<std::string>::iterator end = vec.end(); | |
unsigned int index = 0; | |
for(std::vector<std::string>::iterator it = vec.begin(); it != end; ++it) | |
{ | |
result[++index] = *it; | |
} | |
return result; | |
} | |
... | |
luabind::def("GetFilesInDirectory", &StringVectorAsTable<Helpers::GetFilesInDirectory>), | |
luabind::def("GetDirectoriesInDirectory", &StringVectorAsTable<Helpers::GetDirectoriesInDirectory>), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment