diff options
author | Christian Kandeler <christian.kandeler@nokia.com> | 2012-08-23 15:53:58 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2012-08-27 17:00:03 +0200 |
commit | e669f054069c3a1214a31c4c1d7d9269659c31c4 (patch) | |
tree | d611e865215dc8ee705a640fdf3e35660542632f /src/libs/utils/hostosinfo.cpp | |
parent | b674b59b3d652fa9c5d74dc4e16380e3a5d23882 (diff) |
Utils: Introduce HostOsInfo class.
The class' member functions are intended to be used
instead of the Q_OS_* macros in all contexts where
the latter are not syntactically required.
This lowers the likelihood of changes made on one
platform breaking the build on another, e.g. due to
the code model missing symbols in #ifdef'ed out code
when refactoring.
Change-Id: I4a54788591b4c8f8d589b8368a6c683d4155c9fa
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/libs/utils/hostosinfo.cpp')
-rw-r--r-- | src/libs/utils/hostosinfo.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libs/utils/hostosinfo.cpp b/src/libs/utils/hostosinfo.cpp new file mode 100644 index 00000000000..d00887f719d --- /dev/null +++ b/src/libs/utils/hostosinfo.cpp @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: http://www.qt-project.org/ +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +**************************************************************************/ +#include "hostosinfo.h" + +namespace Utils { + +HostOsInfo::HostOs HostOsInfo::hostOs() +{ +#if defined(Q_OS_WIN) + return HostOsWindows; +#elif defined(Q_OS_LINUX) + return HostOsLinux; +#elif defined(Q_OS_MAC) + return HostOsMac; +#elif defined(Q_OS_UNIX) + return HostOsOtherUnix; +#else + return HostOsOther; +#endif +} + +bool HostOsInfo::isAnyUnixHost() +{ +#ifdef Q_OS_UNIX + return true; +#else + return false; +#endif +} + +} // namespace Utils |