diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-08-03 12:46:15 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-09 21:27:09 +0200 |
commit | fa08b143f3deb1db11984a88aa34d541c19c9fc5 (patch) | |
tree | abbe3ff4f15f148d97edf6bd13eed79a4294d318 /src/corelib/global/qglobal.h | |
parent | 977441f61cc42b7f29e48980577105323fbd3b47 (diff) |
QtGlobal: (new) qEnvironmentVariableIs{Set,Empty}()
These functions are a faster version of {,!}qgetenv().is{Null,Empty}(),
a common pattern in Qt code.
Their main advantage is that they don't need to allocate memory, so
they can be used in noexcept functions, or dynamic initialisation of
namespace-scope statics, because throwing in these contexts invokes
std::terminate().
Change-Id: I651c5bd72f450b5d7df76590f8791572fe992af5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qglobal.h')
-rw-r--r-- | src/corelib/global/qglobal.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5e58f5a4b0..546c6cf575 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1055,6 +1055,9 @@ class QByteArray; Q_CORE_EXPORT QByteArray qgetenv(const char *varName); Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value); +Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT; +Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT; + inline int qIntCast(double f) { return int(f); } inline int qIntCast(float f) { return int(f); } |