diff options
author | Michael Shepanski <michael@codesynthesis.com> | 2014-10-30 15:21:32 +1100 |
---|---|---|
committer | Michael Shepanski <michael@codesynthesis.com> | 2014-10-31 08:39:49 +1100 |
commit | 1f217e38f7507758da1d33d46e675e801621aa38 (patch) | |
tree | bad382ee315a820ec08bd2a83eaece12ac8169e3 /odb/schema-catalog.cxx | |
parent | 31af5a488f2be9f4059e159492d4fe62f25a895a (diff) |
Allow lambdas & std::functions as query factories with C++-98 builds of libodb
Diffstat (limited to 'odb/schema-catalog.cxx')
-rw-r--r-- | odb/schema-catalog.cxx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx index d223647..f2df4e2 100644 --- a/odb/schema-catalog.cxx +++ b/odb/schema-catalog.cxx @@ -38,13 +38,15 @@ namespace odb struct data_function { - typedef schema_catalog::data_migration_function_type function_type; + typedef schema_catalog::data_migration_function_wrapper + function_wrapper_type; data_function () {} - data_function (database_id i, function_type m): id (i), migrate (m) {} + data_function (database_id i, function_wrapper_type m) + : id (i), migrate (m) {} database_id id; - function_type migrate; + function_wrapper_type migrate; }; typedef vector<data_function> data_functions; typedef map<data_key, data_functions> data_map; @@ -218,7 +220,15 @@ namespace odb { if (i->id == id_common || i->id == db.id ()) { - i->migrate (db); + const data_migration_function_wrapper &m = i->migrate; + + if (m.std_function == 0) + m.function (db); + else + { + typedef void (*caller) (const void*, database&); + reinterpret_cast<caller> (m.function) (m.std_function, db); + } r++; } } @@ -229,7 +239,7 @@ namespace odb void schema_catalog:: data_migration_function (database_id id, schema_version v, - data_migration_function_type f, + data_migration_function_wrapper f, const string& name) { // This function can be called from a static initializer in which |