popov-aa

ConnectionParameters.cpp

Feb 7th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include "ConnectionParameters.h"
  2.  
  3. using namespace Atm::DbProvider;
  4.  
  5. ConnectionParameters ConnectionParameters::fromSqlDatabase( const QSqlDatabase & database )
  6. {
  7.     return { database.driverName(),   database.hostName(), (quint16)database.port(),
  8.              database.databaseName(), database.userName(), database.password() };
  9. }
  10.  
  11. QSqlDatabase ConnectionParameters::createSqlDatabase( const QString & connectionName ) const
  12. {
  13.     QSqlDatabase db = QSqlDatabase::addDatabase( driver, connectionName );
  14.     db.setHostName( hostName );
  15.     db.setPort( port );
  16.     db.setDatabaseName( databaseName );
  17.     db.setUserName( userName );
  18.     db.setPassword( password );
  19.     return db;
  20. }
  21.  
  22. bool Atm::DbProvider::ConnectionParameters::operator==( const ConnectionParameters & other ) const
  23. {
  24.     return driver == other.driver && hostName == other.hostName && port == other.port
  25.            && databaseName == other.databaseName && userName == other.userName && password == other.password;
  26. }
  27.  
  28. bool Atm::DbProvider::ConnectionParameters::operator!=( const ConnectionParameters & other ) const
  29. {
  30.     return !( *this == other );
  31. }
Add Comment
Please, Sign In to add comment