From 8e29be9f2229a6c618f95b725502f7082f02d50a Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 22 Mar 2011 10:49:56 +0200 Subject: Add Qt profile example --- qt/database.hxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 qt/database.hxx (limited to 'qt/database.hxx') diff --git a/qt/database.hxx b/qt/database.hxx new file mode 100644 index 0000000..c7c6957 --- /dev/null +++ b/qt/database.hxx @@ -0,0 +1,46 @@ +// file : qt/database.hxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +// +// Create concrete database instance based on the DATABASE_* macros. +// + +#ifndef DATABASE_HXX +#define DATABASE_HXX + +#include +#include // std::auto_ptr +#include // std::exit +#include + +#include + +#if defined(DATABASE_MYSQL) +# include +#endif + +inline std::auto_ptr +create_database (int& argc, char* argv[]) +{ + using namespace std; + using namespace odb::core; + + if (argc > 1 && argv[1] == string ("--help")) + { + cerr << "Usage: " << argv[0] << " [options]" << endl + << "Options:" << endl; + +#if defined(DATABASE_MYSQL) + odb::mysql::database::print_usage (cerr); +#endif + + exit (0); + } + +#if defined(DATABASE_MYSQL) + return auto_ptr (new odb::mysql::database (argc, argv)); +#endif +} + +#endif // DATABASE_HXX -- cgit v1.1