/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010-2014, Tomasz Sowa * All rights reserved. * */ #ifndef headerfile_winix_db_dbconn #define headerfile_winix_db_dbconn #include #include #include "dbtextstream.h" namespace Winix { class DbConn { public: DbConn(); ~DbConn(); void SetConnParam(const std::string & database, const std::string & user, const std::string & pass); void Connect(); void WaitForConnection(); void Close(); bool AssertConnection(bool put_log = true, bool throw_if_no_connection = true); void SetDbParameters(); PGconn * GetPgConn(); private: void LogConnectionSocket(); PGconn * pg_conn; std::string db_database, db_user, db_pass; DbTextStream conn_info; // a helper method for escaping strings template DbTextStream::RawText R(const RawType & par) { return DbTextStream::RawText(par); } }; } // namespace Winix #endif