From 299d10549f5aff50cd6211eb3d3e58c17f13be81 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 21 Apr 2011 19:04:02 +0200 Subject: move key/value converters to the private class this will enable them to access other members later Reviewed-by: thiago Reviewed-by: dt (cherry picked from commit a2d70d71c8c7652ded41d5d603672c3927df44e6) --- src/corelib/io/qprocess.cpp | 29 +++++------------------------ src/corelib/io/qprocess_p.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 20efeae029..ffd5ff0ff8 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -143,25 +143,6 @@ QT_BEGIN_NAMESPACE \sa QProcess, QProcess::systemEnvironment(), QProcess::setProcessEnvironment() */ -#ifdef Q_OS_WIN -static inline QProcessEnvironmentPrivate::Key prepareName(const QString &name) -{ return QProcessEnvironmentPrivate::Key(name); } -static inline QString nameToString(const QProcessEnvironmentPrivate::Key &name) -{ return name; } -static inline QProcessEnvironmentPrivate::Value prepareValue(const QString &value) -{ return value; } -static inline QString valueToString(const QProcessEnvironmentPrivate::Value &value) -{ return value; } -#else -static inline QProcessEnvironmentPrivate::Key prepareName(const QString &name) -{ return name.toLocal8Bit(); } -static inline QString nameToString(const QProcessEnvironmentPrivate::Key &name) -{ return QString::fromLocal8Bit(name); } -static inline QProcessEnvironmentPrivate::Value prepareValue(const QString &value) -{ return value.toLocal8Bit(); } -static inline QString valueToString(const QProcessEnvironmentPrivate::Value &value) -{ return QString::fromLocal8Bit(value); } -#endif template<> void QSharedDataPointer::detach() { @@ -321,7 +302,7 @@ void QProcessEnvironment::clear() */ bool QProcessEnvironment::contains(const QString &name) const { - return d ? d->hash.contains(prepareName(name)) : false; + return d ? d->hash.contains(d->prepareName(name)) : false; } /*! @@ -343,7 +324,7 @@ bool QProcessEnvironment::contains(const QString &name) const void QProcessEnvironment::insert(const QString &name, const QString &value) { // d detaches from null - d->hash.insert(prepareName(name), prepareValue(value)); + d->hash.insert(d->prepareName(name), d->prepareValue(value)); } /*! @@ -360,7 +341,7 @@ void QProcessEnvironment::insert(const QString &name, const QString &value) void QProcessEnvironment::remove(const QString &name) { if (d) - d->hash.remove(prepareName(name)); + d->hash.remove(d->prepareName(name)); } /*! @@ -379,11 +360,11 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa if (!d) return defaultValue; - QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(prepareName(name)); + QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name)); if (it == d->hash.constEnd()) return defaultValue; - return valueToString(it.value()); + return d->valueToString(it.value()); } /*! diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 2d4c55670d..14fc9f32ce 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -95,9 +95,19 @@ public: }; typedef QString Value; + + 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 typedef QByteArray Key; typedef QByteArray Value; + + inline Key prepareName(const QString &name) const { return name.toLocal8Bit(); } + inline QString nameToString(const Key &name) const { return QString::fromLocal8Bit(name); } + inline Value prepareValue(const QString &value) const { return value.toLocal8Bit(); } + inline QString valueToString(const Value &value) const { return QString::fromLocal8Bit(value); } #endif typedef QHash Hash; -- cgit v1.2.3