// file : odb/pgsql/database.hxx // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #ifndef ODB_PGSQL_DATABASE_HXX #define ODB_PGSQL_DATABASE_HXX #include #include #include // std::auto_ptr, std::unique_ptr #include // std::ostream #include #include #include #include #include #include #include #include #include namespace odb { namespace pgsql { class transaction_impl; class LIBODB_PGSQL_EXPORT database: public odb::database { public: database (const std::string& user, const std::string& password, const std::string& db, const std::string& host = "", unsigned int port = 0, const std::string& extra_conninfo = "", details::transfer_ptr = details::transfer_ptr ()); database (const std::string& user, const std::string& password, const std::string& db, const std::string& host = "", const std::string& socket_ext = "", const std::string& extra_conninfo = "", details::transfer_ptr = details::transfer_ptr ()); explicit database (const std::string& conninfo, details::transfer_ptr = details::transfer_ptr ()); // 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 = "", details::transfer_ptr = details::transfer_ptr ()); static void print_usage (std::ostream&); // Transactions. // public: virtual transaction_impl* begin (); public: connection_ptr connection (); public: virtual ~database (); protected: virtual odb::connection* connection_ (); // SQL statement tracing. // public: typedef pgsql::tracer tracer_type; void tracer (tracer_type& t) { odb::database::tracer (t); } void tracer (tracer_type* t) { odb::database::tracer (t); } using odb::database::tracer; public: const std::string& user () const { return user_; } const std::string& password () const { return password_; } const std::string& db () const { return db_; } const std::string& host () const { return host_; } 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_; details::unique_ptr factory_; }; } } #include #include #endif // ODB_PGSQL_DATABASE_HXX