From 95e57339a9c02943edbd0cc7d4470a2ed044a7c2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 2 May 2011 11:06:27 +0200 Subject: fix build on symbian Error: #793: explicit specialization of class "QTypeInfo" must precede its first use just un-nest QProcessEnvironmentPrivate::{Key,Value} Reviewed-by: thiago (cherry picked from commit 167044693cc1d16684a5732b05e3926d0af61960) --- src/corelib/io/qprocess_p.h | 122 ++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 62 deletions(-) (limited to 'src/corelib/io/qprocess_p.h') diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 251f8bc772..f70579bd17 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -81,68 +81,76 @@ class QTimer; class RProcess; #endif -class QProcessEnvironmentPrivate: public QSharedData +#ifdef Q_OS_WIN +class QProcEnvKey : public QString { public: -#ifdef Q_OS_WIN - class Key : public QString + QProcEnvKey() {} + explicit QProcEnvKey(const QString &other) : QString(other) {} + QProcEnvKey(const QProcEnvKey &other) : QString(other) {} + bool operator==(const QProcEnvKey &other) const { return !compare(other, Qt::CaseInsensitive); } +}; +inline uint qHash(const QProcEnvKey &key) { return qHash(key.toCaseFolded()); } + +typedef QString QProcEnvValue; +#else +class QProcEnvKey +{ +public: + QProcEnvKey() : hash(0) {} + explicit QProcEnvKey(const QByteArray &other) : key(other), hash(qHash(key)) {} + QProcEnvKey(const QProcEnvKey &other) { *this = other; } + bool operator==(const QProcEnvKey &other) const { return key == other.key; } + + QByteArray key; + uint hash; +}; +inline uint qHash(const QProcEnvKey &key) { return key.hash; } + +class QProcEnvValue +{ +public: + QProcEnvValue() {} + QProcEnvValue(const QProcEnvValue &other) { *this = other; } + explicit QProcEnvValue(const QString &value) : stringValue(value) {} + explicit QProcEnvValue(const QByteArray &value) : byteValue(value) {} + bool operator==(const QProcEnvValue &other) const { - public: - Key() {} - explicit Key(const QString &other) : QString(other) {} - Key(const Key &other) : QString(other) {} - bool operator==(const Key &other) const { return !compare(other, Qt::CaseInsensitive); } - }; + return byteValue.isEmpty() && other.byteValue.isEmpty() + ? stringValue == other.stringValue + : bytes() == other.bytes(); + } + QByteArray bytes() const + { + if (byteValue.isEmpty() && !stringValue.isEmpty()) + byteValue = stringValue.toLocal8Bit(); + return byteValue; + } + QString string() const + { + if (stringValue.isEmpty() && !byteValue.isEmpty()) + stringValue = QString::fromLocal8Bit(byteValue); + return stringValue; + } - typedef QString Value; + mutable QByteArray byteValue; + mutable QString stringValue; +}; +Q_DECLARE_TYPEINFO(QProcEnvValue, Q_MOVABLE_TYPE); +#endif +Q_DECLARE_TYPEINFO(QProcEnvKey, Q_MOVABLE_TYPE); +class QProcessEnvironmentPrivate: public QSharedData +{ +public: + typedef QProcEnvKey Key; + typedef QProcEnvValue Value; +#ifdef Q_OS_WIN inline Key prepareName(const QString &name) const { return Key(name); } inline QString nameToString(const Key &name) const { return name; } inline Value prepareValue(const QString &value) const { return value; } inline QString valueToString(const Value &value) const { return value; } #else - class Key - { - public: - Key() : hash(0) {} - explicit Key(const QByteArray &other) : key(other), hash(qHash(key)) {} - Key(const Key &other) { *this = other; } - bool operator==(const Key &other) const { return key == other.key; } - - QByteArray key; - uint hash; - }; - - class Value - { - public: - Value() {} - Value(const Value &other) { *this = other; } - explicit Value(const QString &value) : stringValue(value) {} - explicit Value(const QByteArray &value) : byteValue(value) {} - bool operator==(const Value &other) const - { - return byteValue.isEmpty() && other.byteValue.isEmpty() - ? stringValue == other.stringValue - : bytes() == other.bytes(); - } - QByteArray bytes() const - { - if (byteValue.isEmpty() && !stringValue.isEmpty()) - byteValue = stringValue.toLocal8Bit(); - return byteValue; - } - QString string() const - { - if (stringValue.isEmpty() && !byteValue.isEmpty()) - stringValue = QString::fromLocal8Bit(byteValue); - return stringValue; - } - - mutable QByteArray byteValue; - mutable QString stringValue; - }; - inline Key prepareName(const QString &name) const { Key &ent = nameMap[name]; @@ -173,16 +181,6 @@ public: QStringList keys() const; void insert(const QProcessEnvironmentPrivate &other); }; -Q_DECLARE_TYPEINFO(QProcessEnvironmentPrivate::Key, Q_MOVABLE_TYPE); -#ifdef Q_OS_UNIX -Q_DECLARE_TYPEINFO(QProcessEnvironmentPrivate::Value, Q_MOVABLE_TYPE); -#endif - -#ifdef Q_OS_WIN -inline uint qHash(const QProcessEnvironmentPrivate::Key &key) { return qHash(key.toCaseFolded()); } -#else -inline uint qHash(const QProcessEnvironmentPrivate::Key &key) { return key.hash; } -#endif class QProcessPrivate : public QIODevicePrivate { -- cgit v1.2.3