From 0c370d056fe0848c8a9cf11c48e423f3f2e97264 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 14 Sep 2010 12:00:03 +0200 Subject: Use options parsing from database instead of our own --- libcommon/common/common.cxx | 55 +++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 37 deletions(-) (limited to 'libcommon/common/common.cxx') diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx index ed8be69..730b8ce 100644 --- a/libcommon/common/common.cxx +++ b/libcommon/common/common.cxx @@ -10,58 +10,39 @@ # include #endif -#ifdef DB_ID_MYSQL +#if defined(DB_ID_MYSQL) # include # include +#else +# error unknown database #endif #include -#include using namespace std; using namespace odb; auto_ptr -create_database (int argc, char* argv[], size_t max_connections) +create_database (int& argc, char* argv[], size_t max_connections) { - try + if (argc > 1 && argv[1] == string ("--help")) { -#ifdef DB_ID_MYSQL - cli::argv_file_scanner scan (argc, argv, "--options-file"); - cli::mysql_options ops (scan); + cerr << "Usage: " << argv[0] << " [options]" << endl + << "Options:" << endl; - if (ops.help ()) - { - cerr << "Usage: " << argv[0] << " [options]" << endl - << "Options:" << endl; - cli::mysql_options::print_usage (cerr); - exit (0); - } +#if defined(DB_ID_MYSQL) + mysql::database::print_usage (cerr); +#endif - auto_ptr f; + exit (0); + } - if (max_connections != 0) - f.reset (new mysql::connection_pool_factory (max_connections)); +#if defined(DB_ID_MYSQL) + auto_ptr f; - return auto_ptr ( - new mysql::database ( - ops.user (), - ops.password_specified () ? &ops.password () : 0, - ops.database (), - ops.host (), - ops.port (), - ops.socket_specified () ? &ops.socket () : 0, - 0, - f)); -#else - return auto_ptr (0); -#endif - } - catch (const cli::exception& e) - { - cerr << e.what () << endl; - exit (1); - } + if (max_connections != 0) + f.reset (new mysql::connection_pool_factory (max_connections)); - return auto_ptr (0); + return auto_ptr (new mysql::database (argc, argv, false, 0, f)); +#endif } -- cgit v1.1