aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/hostosinfo.h
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@nokia.com>2012-08-23 15:53:58 +0200
committerhjk <qthjk@ovi.com>2012-08-27 17:00:03 +0200
commite669f054069c3a1214a31c4c1d7d9269659c31c4 (patch)
treed611e865215dc8ee705a640fdf3e35660542632f /src/libs/utils/hostosinfo.h
parentb674b59b3d652fa9c5d74dc4e16380e3a5d23882 (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.h')
-rw-r--r--src/libs/utils/hostosinfo.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/libs/utils/hostosinfo.h b/src/libs/utils/hostosinfo.h
new file mode 100644
index 00000000000..e456ff7e73f
--- /dev/null
+++ b/src/libs/utils/hostosinfo.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+**
+** 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.
+**
+**
+**************************************************************************/
+#ifndef HOSTOSINFO_H
+#define HOSTOSINFO_H
+
+#include "utils_global.h"
+
+namespace Utils {
+
+class QTCREATOR_UTILS_EXPORT HostOsInfo
+{
+public:
+ // Add more as needed.
+ enum HostOs { HostOsWindows, HostOsLinux, HostOsMac, HostOsOtherUnix, HostOsOther };
+
+ static HostOs hostOs();
+
+ static bool isWindowsHost() { return hostOs() == HostOsWindows; }
+ static bool isLinuxHost() { return hostOs() == HostOsLinux; }
+ static bool isMacHost() { return hostOs() == HostOsMac; }
+ static bool isAnyUnixHost();
+};
+
+} // namespace Utils
+
+#endif // HOSTOSINFO_H