Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef CONNECTIONPARAMETERS_H
- #define CONNECTIONPARAMETERS_H
- #include <QDebug>
- #include <QSqlDatabase>
- #include <QString>
- namespace Atm { namespace DbProvider {
- struct ConnectionParameters
- {
- QString driver;
- QString hostName;
- quint16 port;
- QString databaseName;
- QString userName;
- QString password;
- static ConnectionParameters fromSqlDatabase( const QSqlDatabase & database );
- QSqlDatabase createSqlDatabase(
- const QString & connectionName = QLatin1String( QSqlDatabase::defaultConnection ) ) const;
- friend QDebug & operator<<( QDebug & d, const ConnectionParameters & p )
- {
- bool space = d.autoInsertSpaces();
- if ( p.driver == "QSQLITE" ) {
- d.noquote().nospace() << p.databaseName;
- } else {
- if ( !p.userName.isEmpty() ) {
- d.noquote().nospace() << p.userName << "@";
- }
- d.noquote().nospace() << p.hostName << ":" << p.port << "\\" << p.databaseName;
- }
- d.setAutoInsertSpaces( space );
- return d.maybeSpace();
- }
- bool operator==( const ConnectionParameters & other ) const;
- bool operator!=( const ConnectionParameters & other ) const;
- };
- }} // namespace Atm::DbProvider
- #endif // CONNECTIONPARAMETERS_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement