summaryrefslogtreecommitdiff
path: root/odb-tests/libcommon/common.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb-tests/libcommon/common.hxx')
-rw-r--r--odb-tests/libcommon/common.hxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/odb-tests/libcommon/common.hxx b/odb-tests/libcommon/common.hxx
new file mode 100644
index 0000000..9ab978d
--- /dev/null
+++ b/odb-tests/libcommon/common.hxx
@@ -0,0 +1,47 @@
+// file : libcommon/common.hxx
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef LIBCOMMON_COMMON_HXX
+#define LIBCOMMON_COMMON_HXX
+
+#include <memory> // std::unique_ptr
+#include <cstddef> // std::size_t
+
+#include <odb/result.hxx>
+#include <odb/database.hxx>
+
+#include <libcommon/export.hxx>
+
+LIBCOMMON_SYMEXPORT std::unique_ptr<odb::database>
+create_database (int argc,
+ char* argv[],
+ bool create_schema = true,
+ std::size_t max_connections = 0,
+ odb::database_id db = odb::id_common);
+
+template <typename T>
+std::unique_ptr<T>
+create_specific_database (int argc,
+ char* argv[],
+ bool create_schema = true,
+ std::size_t max_connections = 0)
+{
+ std::unique_ptr<odb::database> r (
+ create_database (argc, argv,
+ create_schema,
+ max_connections,
+ T::database_id));
+
+ return std::unique_ptr<T> (&dynamic_cast<T&> (*r.release ()));
+}
+
+// This function returns an accurate result only if the result iterator
+// hasn't been advanced and after the call the result is no longer valid.
+//
+template <typename T>
+std::size_t
+size (odb::result<T>);
+
+#include <libcommon/common.txx>
+
+#endif // LIBCOMMON_COMMON_HXX