KDb

KDbConnectionOptions.h
1/* This file is part of the KDE project
2 Copyright (C) 2003-2016 Jarosław Staniek <staniek@kde.org>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KDB_CONNECTIONOPTIONS_H
21#define KDB_CONNECTIONOPTIONS_H
22
23#include <QCoreApplication>
24#include "KDbUtils.h"
25
26class KDbConnectionPrivate;
27class KDbConnection;
28
29/*! @brief Generic options for a single connection.
30 The options are accessible using key/value pairs. This enables extensibility
31 depending on driver's type and version.
32 @see KDbDriver::createConnection(const KDbConnectionData&, const KDbConnectionOptions&)
33 @see KDbConnection::options()
34*/
36{
37 Q_DECLARE_TR_FUNCTIONS(KDbConnectionOptions)
38public:
40
42
44
46
47 //! @return true if these options have exactly the same values as @a other
48 //! @since 3.1
49 bool operator==(const KDbConnectionOptions &other) const;
50
51 //! @return true if these options differs in at least one value from @a other
52 //! @since 3.1
53 bool operator!=(const KDbConnectionOptions &other) const { return !operator==(other); }
54
55 /*! @return true for read-only connection. Used especially for file-based drivers.
56 Can be implemented in a driver to provide real read-only flag of the connection
57 (sqlite driver does this). */
58 bool isReadOnly() const;
59
60 /*! @internal used by KDbDriver::createConnection().
61 Only works if connection is not yet established. */
62 void setReadOnly(bool set);
63
64 //! Inserts option with a given @a name, @a value and @a caption.
65 //! If such option exists, value is updated but caption only if existing caption is empty.
66 //! @a name must be a valid identifier (see KDb::isIdentifier()).
67 void insert(const QByteArray &name, const QVariant &value, const QString &caption = QString());
68
69 //! Sets caption for option @a name to @a caption.
70 //! If such option does not exist, does nothing.
71 void setCaption(const QByteArray &name, const QString &caption);
72
73 //! Sets value for option @a name to @a value.
74 //! If such option does not exist, does nothing.
75 //! @since 3.1
76 void setValue(const QByteArray &name, const QVariant &value);
77
78 //! Removes option with a given @a name if exists.
79 void remove(const QByteArray &name);
80
81private:
82 void setConnection(KDbConnection *connection);
83
84 friend class KDbConnectionPrivate;
85
86 class Private;
87 Private * const d;
88};
89
90#endif
Generic options for a single connection. The options are accessible using key/value pairs....
bool operator!=(const KDbConnectionOptions &other) const
Provides database connection, allowing queries and data modification.
A set of properties.
Definition KDbUtils.h:480
void setValue(const QByteArray &name, const QVariant &value)
Sets value for property name to value.
Definition KDbUtils.cpp:686
void remove(const QByteArray &name)
Removes property with a given name.
Definition KDbUtils.cpp:694
PropertySet & operator=(const PropertySet &other)
Assigns other to this property set and returns a reference to this property set.
Definition KDbUtils.cpp:646
void setCaption(const QByteArray &name, const QString &caption)
Sets caption for property name to caption.
Definition KDbUtils.cpp:678
void insert(const QByteArray &name, const QVariant &value, const QString &caption=QString())
Inserts property with a given name, value and caption.
Definition KDbUtils.cpp:660
bool operator==(const PropertySet &other) const
Definition KDbUtils.cpp:655
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.