diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-09-08 21:23:37 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-09-08 21:23:37 +0200 |
commit | ff5bb2accee87c24ee64e8fdcf5169e674c4b7b4 (patch) | |
tree | 321a74c1f48331cb44e3b90943501646c5024836 /libcommon/common/common.cxx | |
parent | b3b1fac433a20e5ab6abb3729ecc5473a658718b (diff) |
Add suppor for VC++ build
Diffstat (limited to 'libcommon/common/common.cxx')
-rw-r--r-- | libcommon/common/common.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx new file mode 100644 index 0000000..d68d579 --- /dev/null +++ b/libcommon/common/common.cxx @@ -0,0 +1,49 @@ +// file : libcommon/common/common.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include <cstdlib> // std::exit +#include <iostream> + +#ifndef _MSC_VER +# include <common/config.h> +#endif + +#ifdef DB_ID_MYSQL +# include <odb/mysql/database.hxx> +#endif + +#include <common/common.hxx> +#include <common/options.hxx> + +using namespace std; +using namespace odb; + +auto_ptr<database> +create_database (int argc, char* argv[]) +{ +#ifdef DB_ID_MYSQL + cli::argv_file_scanner scan (argc, argv, "--options-file"); + cli::mysql_options ops (scan); + + if (ops.help ()) + { + cerr << "Usage: " << argv[0] << " [options]" << endl + << "Options:" << endl; + cli::mysql_options::print_usage (cerr); + exit (0); + } + + return auto_ptr<database> ( + new mysql::database ( + ops.user (), + ops.passwd_specified () ? &ops.passwd () : 0, + ops.db_name (), + ops.host (), + ops.port (), + ops.socket_specified () ? &ops.socket () : 0)); +#else + return auto_ptr<database> (0); +#endif +} |