summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorMarcel Krems <m.krems@software-vision.eu>2013-12-17 07:57:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-20 10:46:12 +0100
commita14f26234bd669785f01349fbaacad7e73b78790 (patch)
treeb56aabd628d7e55722d8edf4776ca9c440f082c1 /src/sql
parente4a910eb2afb85ea0daa64441215f917389a052d (diff)
Move QSqlError private members into a pimpl class.
This allows us to add new members without breaking BC. Change-Id: I59236cd5eeacdcfc490849a18b3bdf70d7a501bf Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/kernel/qsqlerror.cpp57
-rw-r--r--src/sql/kernel/qsqlerror.h15
2 files changed, 46 insertions, 26 deletions
diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp
index e4b8aa0c6d..a2ae453756 100644
--- a/src/sql/kernel/qsqlerror.cpp
+++ b/src/sql/kernel/qsqlerror.cpp
@@ -53,6 +53,16 @@ QDebug operator<<(QDebug dbg, const QSqlError &s)
}
#endif
+class QSqlErrorPrivate
+{
+public:
+ QString driverError;
+ QString databaseError;
+ QSqlError::ErrorType errorType;
+ int errorNumber;
+};
+
+
/*!
\class QSqlError
\brief The QSqlError class provides SQL database error information.
@@ -88,18 +98,23 @@ QDebug operator<<(QDebug dbg, const QSqlError &s)
QSqlError::QSqlError(const QString& driverText, const QString& databaseText, ErrorType type,
int number)
- : driverError(driverText), databaseError(databaseText), errorType(type), errorNumber(number)
{
+ d = new QSqlErrorPrivate;
+
+ d->driverError = driverText;
+ d->databaseError = databaseText;
+ d->errorType = type;
+ d->errorNumber = number;
}
/*!
Creates a copy of \a other.
*/
QSqlError::QSqlError(const QSqlError& other)
- : driverError(other.driverError), databaseError(other.databaseError),
- errorType(other.errorType),
- errorNumber(other.errorNumber)
{
+ d = new QSqlErrorPrivate;
+
+ *d = *other.d;
}
/*!
@@ -108,10 +123,7 @@ QSqlError::QSqlError(const QSqlError& other)
QSqlError& QSqlError::operator=(const QSqlError& other)
{
- driverError = other.driverError;
- databaseError = other.databaseError;
- errorType = other.errorType;
- errorNumber = other.errorNumber;
+ *d = *other.d;
return *this;
}
@@ -121,7 +133,7 @@ QSqlError& QSqlError::operator=(const QSqlError& other)
bool QSqlError::operator==(const QSqlError& other) const
{
- return (errorType == other.errorType);
+ return (d->errorType == other.d->errorType);
}
@@ -131,7 +143,7 @@ bool QSqlError::operator==(const QSqlError& other) const
bool QSqlError::operator!=(const QSqlError& other) const
{
- return (errorType != other.errorType);
+ return (d->errorType != other.d->errorType);
}
@@ -141,6 +153,7 @@ bool QSqlError::operator!=(const QSqlError& other) const
QSqlError::~QSqlError()
{
+ delete d;
}
/*!
@@ -151,7 +164,7 @@ QSqlError::~QSqlError()
*/
QString QSqlError::driverText() const
{
- return driverError;
+ return d->driverError;
}
/*!
@@ -169,7 +182,7 @@ QString QSqlError::driverText() const
#if QT_DEPRECATED_SINCE(5, 1)
void QSqlError::setDriverText(const QString& driverText)
{
- driverError = driverText;
+ d->driverError = driverText;
}
#endif
@@ -182,7 +195,7 @@ void QSqlError::setDriverText(const QString& driverText)
QString QSqlError::databaseText() const
{
- return databaseError;
+ return d->databaseError;
}
/*!
@@ -200,7 +213,7 @@ QString QSqlError::databaseText() const
#if QT_DEPRECATED_SINCE(5, 1)
void QSqlError::setDatabaseText(const QString& databaseText)
{
- databaseError = databaseText;
+ d->databaseError = databaseText;
}
#endif
@@ -210,7 +223,7 @@ void QSqlError::setDatabaseText(const QString& databaseText)
QSqlError::ErrorType QSqlError::type() const
{
- return errorType;
+ return d->errorType;
}
/*!
@@ -228,7 +241,7 @@ QSqlError::ErrorType QSqlError::type() const
#if QT_DEPRECATED_SINCE(5, 1)
void QSqlError::setType(ErrorType type)
{
- errorType = type;
+ d->errorType = type;
}
#endif
@@ -239,7 +252,7 @@ void QSqlError::setType(ErrorType type)
int QSqlError::number() const
{
- return errorNumber;
+ return d->errorNumber;
}
/*!
@@ -257,7 +270,7 @@ int QSqlError::number() const
#if QT_DEPRECATED_SINCE(5, 1)
void QSqlError::setNumber(int number)
{
- errorNumber = number;
+ d->errorNumber = number;
}
#endif
@@ -270,10 +283,10 @@ void QSqlError::setNumber(int number)
QString QSqlError::text() const
{
- QString result = databaseError;
- if (!databaseError.endsWith(QLatin1String("\n")))
+ QString result = d->databaseError;
+ if (!d->databaseError.endsWith(QLatin1String("\n")))
result += QLatin1Char(' ');
- result += driverError;
+ result += d->driverError;
return result;
}
@@ -287,7 +300,7 @@ QString QSqlError::text() const
*/
bool QSqlError::isValid() const
{
- return errorType != NoError;
+ return d->errorType != NoError;
}
QT_END_NAMESPACE
diff --git a/src/sql/kernel/qsqlerror.h b/src/sql/kernel/qsqlerror.h
index 39c4cda958..0efe0e07b0 100644
--- a/src/sql/kernel/qsqlerror.h
+++ b/src/sql/kernel/qsqlerror.h
@@ -47,6 +47,7 @@
QT_BEGIN_NAMESPACE
+class QSqlErrorPrivate;
class Q_SQL_EXPORT QSqlError
{
@@ -83,10 +84,16 @@ public:
#endif
private:
- QString driverError;
- QString databaseError;
- ErrorType errorType;
- int errorNumber;
+ // ### Qt6: Keep the pointer and remove the rest.
+ QString unused1;
+ QString unused2;
+ union {
+ QSqlErrorPrivate *d;
+ struct {
+ ErrorType unused3;
+ int unused4;
+ } unused5;
+ };
};
#ifndef QT_NO_DEBUG_STREAM