FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
database_settings.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (30 Mar. 2015)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 class QSettings;
19 class QSqlDatabase;
20 
21 #include "sql.h"
22 #include <QtCore/QByteArray>
23 #include <QtCore/QHash>
24 #include <QtCore/QVariant>
25 #include <functional>
26 
27 namespace qtsql {
28 
30 {
31 public:
32  typedef std::function<QByteArray (const QByteArray&)> CipherFunction;
33  typedef QHash<QString, QVariant> ValuesHash;
34 
36 
37  const QString& host() const;
38  void setHost(const QString& host);
39 
40  QString databaseName() const;
41  void setDatabaseName(const QString& dbName);
42 
43  int port() const;
44  void setPort(int port);
45 
46  const QString& userName() const;
47  void setUserName(const QString& userName);
48 
49  const QString& password() const;
50  void setPassword(const QString& password);
51 
52  void applyTo(QSqlDatabase* db) const;
53 
54  void load(const QSettings* settings,
55  CipherFunction&& pwdCipherFunc,
56  const ValuesHash& defValues = ValuesHash());
57  void write(QSettings* settings,
58  CipherFunction&& pwdCipherFunc) const;
59 
60 private:
61  QString m_host;
62  QString m_dbName;
63  int m_port;
64  QString m_userName;
65  QString m_password;
66 };
67 
68 } // namespace qtsql
QHash< QString, QVariant > ValuesHash
Definition: database_settings.h:33
#define QTTOOLS_SQL_EXPORT
Definition: sql.h:27
Settings to connect to a database. Settings can be loaded and saved from/to a QSettings.
Definition: database_settings.h:29
std::function< QByteArray(const QByteArray &)> CipherFunction
Definition: database_settings.h:32
Definition: composite_type_helper.cpp:21