Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Database::Execute(std::string const& query, RowHandler handler)
- {
- // Create a closure that matches the callback signature sqlite3_exec wants.
- // Handler param passed as user data, so cast that to the correct type and call it.
- // Explicitly setting return type as int isn't 100% necessary as it can be deduced
- // from return type of RowHandler.
- auto wrapper = [](void* userData, int columnCount, char **columnValues, char **columnNames) -> int
- {
- auto handler = reinterpret_cast<RowHandler*>(userData);
- return (*handler)(columnCount, columnValues, columnNames);
- };
- return sqlite3_exec(db, query.c_str(), wrapper, &handler, /* error handling can wait */ nullptr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement