diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-05-03 12:26:33 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-05-05 16:42:12 +0200 |
commit | 77bbae6038d20576a4807ed8ca834685a1e85afa (patch) | |
tree | 1d079baf6d2aa379bd2a04efb5617302309bb671 /odb/pgsql/database.hxx | |
parent | 00eab4e6eca4227b1ecd2c6f502eedad41c3af96 (diff) |
Add pgsql database implementation
Diffstat (limited to 'odb/pgsql/database.hxx')
-rw-r--r-- | odb/pgsql/database.hxx | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/odb/pgsql/database.hxx b/odb/pgsql/database.hxx new file mode 100644 index 0000000..fbd15b9 --- /dev/null +++ b/odb/pgsql/database.hxx @@ -0,0 +1,167 @@ +// file : odb/pgsql/database.hxx +// author : Constantin Michael <constantin@codesynthesis.com> +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_PGSQL_DATABASE_HXX +#define ODB_PGSQL_DATABASE_HXX + +#include <odb/pre.hxx> + +#include <string> +#include <memory> // std::auto_ptr +#include <iosfwd> // std::ostream + +#include <odb/database.hxx> + +#include <odb/pgsql/version.hxx> +#include <odb/pgsql/forward.hxx> + +#include <odb/pgsql/details/export.hxx> + +namespace odb +{ + namespace pgsql + { + class LIBODB_PGSQL_EXPORT database: public odb::database + { + public: + database (const std::string& db, + const std::string& user, + const std::string& password, + const std::string& host = "", + unsigned int port = 0, + const std::string& extra_conninfo = "", + std::auto_ptr<connection_factory> factory = + std::auto_ptr<connection_factory> (0)); + + database (const std::string& db, + const std::string& user, + const std::string& password, + const std::string& host = "", + const std::string& socket_ext = "", + const std::string& extra_conninfo = "", + std::auto_ptr<connection_factory> factory = + std::auto_ptr<connection_factory> (0)); + + explicit + database (const std::string& conninfo, + std::auto_ptr<connection_factory> = + std::auto_ptr<connection_factory> (0)); + + // Extract the database parameters from the command line. The + // following options are recognized: + // + // --user | --username + // --password + // --database | --dbname + // --host + // --port + // --options-file + // + // For more information, see the output of the print_usage() function + // below. If erase is true, the above options are removed from the + // argv array and the argc count is updated accordingly. This + // constructor may throw the cli_exception exception. + // + database (int& argc, + char* argv[], + bool erase = false, + const std::string& extra_conninfo = "", + std::auto_ptr<connection_factory> = + std::auto_ptr<connection_factory> (0)); + + static void + print_usage (std::ostream&); + + public: + // @@ Implement on completion of supporting code. + // + // using odb::database::execute; + // virtual unsigned long long + // execute (const char* statement, std::size_t length); + + public: + // @@ Implement on completion of supporting code. + // + // virtual transaction_impl* + // begin (); + + public: + // @@ Implement on completion of supporting code. + // + // details::shared_ptr<connection_type> + // connection (); + + public: + virtual + ~database (); + + public: + const std::string& + host () const + { + return host_; + } + + const std::string& + db () const + { + return db_; + } + + const std::string& + user () const + { + return user_; + } + + const std::string& + password () const + { + return password_; + } + + unsigned int + port () const + { + return port_; + } + + const std::string& + socket_ext () const + { + return socket_ext_; + } + + const std::string& + extra_conninfo () const + { + return extra_conninfo_; + } + + const std::string& + conninfo () const + { + return conninfo_; + } + + private: + std::string user_; + std::string password_; + std::string db_; + std::string host_; + unsigned int port_; + std::string socket_ext_; + std::string extra_conninfo_; + std::string conninfo_; + std::auto_ptr<connection_factory> factory_; + }; + } +} + +#include <odb/pgsql/database.ixx> + +#include <odb/post.hxx> + +#endif // ODB_PGSQL_DATABASE_HXX |