From fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 13 Dec 2023 21:57:53 +0300 Subject: Switch to build2 --- libcommon/common.hxx | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 libcommon/common.hxx (limited to 'libcommon/common.hxx') diff --git a/libcommon/common.hxx b/libcommon/common.hxx new file mode 100644 index 0000000..9ab978d --- /dev/null +++ b/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 // std::unique_ptr +#include // std::size_t + +#include +#include + +#include + +LIBCOMMON_SYMEXPORT std::unique_ptr +create_database (int argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0, + odb::database_id db = odb::id_common); + +template +std::unique_ptr +create_specific_database (int argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0) +{ + std::unique_ptr r ( + create_database (argc, argv, + create_schema, + max_connections, + T::database_id)); + + return std::unique_ptr (&dynamic_cast (*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 +std::size_t +size (odb::result); + +#include + +#endif // LIBCOMMON_COMMON_HXX -- cgit v1.1