FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
qtsql::DatabaseSettings Class Reference

Settings to connect to a database. Settings can be loaded and saved from/to a QSettings. More...

#include <qttools/sql/database_settings.h>

Public Types

typedef std::function
< QByteArray(const QByteArray &)> 
CipherFunction
 
typedef QHash< QString, QVariant > ValuesHash
 

Public Member Functions

 DatabaseSettings ()
 
const QString & host () const
 
void setHost (const QString &host)
 
QString databaseName () const
 
void setDatabaseName (const QString &dbName)
 
int port () const
 
void setPort (int port)
 
const QString & userName () const
 
void setUserName (const QString &userName)
 
const QString & password () const
 
void setPassword (const QString &password)
 
void applyTo (QSqlDatabase *db) const
 Apply the current settings to a QSqlDatabase instance. More...
 
void load (const QSettings *settings, CipherFunction &&pwdCipherFunc, const ValuesHash &defValues=ValuesHash())
 Load settings from the persistent storage. More...
 
void write (QSettings *settings, CipherFunction &&pwdCipherFunc) const
 Write settings to persistent storage. More...
 

Detailed Description

Settings to connect to a database. Settings can be loaded and saved from/to a QSettings.

Member Typedef Documentation

typedef std::function<QByteArray (const QByteArray&)> qtsql::DatabaseSettings::CipherFunction
typedef QHash<QString, QVariant> qtsql::DatabaseSettings::ValuesHash

Constructor & Destructor Documentation

qtsql::DatabaseSettings::DatabaseSettings ( )

Member Function Documentation

void qtsql::DatabaseSettings::applyTo ( QSqlDatabase *  db) const

Apply the current settings to a QSqlDatabase instance.

Note
It does not close/open the connection of db
QString qtsql::DatabaseSettings::databaseName ( ) const
See also
QSqlDatabase::databaseName()
const QString & qtsql::DatabaseSettings::host ( ) const
See also
QSqlDatabase::hostName()
void qtsql::DatabaseSettings::load ( const QSettings *  settings,
CipherFunction &&  pwdCipherFunc,
const ValuesHash defValues = ValuesHash() 
)

Load settings from the persistent storage.

Parameters
pwdCipherFuncFunction used to decrypt the password. If null then the default password is returned (see parameter defValues)
defValuesDefault values when all or some persistent settings could not be retrieved
const QString & qtsql::DatabaseSettings::password ( ) const
See also
QSqlDatabase::password()
int qtsql::DatabaseSettings::port ( ) const
See also
QSqlDatabase::port()
void qtsql::DatabaseSettings::setDatabaseName ( const QString &  dbName)
See also
QSqlDatabase::setDatabaseName()
void qtsql::DatabaseSettings::setHost ( const QString &  host)
See also
QSqlDatabase::setHostName()
void qtsql::DatabaseSettings::setPassword ( const QString &  password)
See also
QSqlDatabase::setPassword()
void qtsql::DatabaseSettings::setPort ( int  port)
See also
QSqlDatabase::setPort()
void qtsql::DatabaseSettings::setUserName ( const QString &  userName)
See also
QSqlDatabase::setUserName()
const QString & qtsql::DatabaseSettings::userName ( ) const
See also
QSqlDatabase::userName()
void qtsql::DatabaseSettings::write ( QSettings *  settings,
CipherFunction &&  pwdCipherFunc 
) const

Write settings to persistent storage.

Parameters
pwdCipherFuncFunction used to encrypt the password. If null then an empty password is stored. Otherwise the password() is reprensented as a UTF-8 byte array and passed to pwdCipherFunc

The documentation for this class was generated from the following files: