dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
hostosinfo.h
Go to the documentation of this file.
1 /**************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and Digia. For licensing terms and
13 ** conditions see http://qt.digia.com/licensing. For further information
14 ** use the contact form at http://qt.digia.com/contact-us.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Digia gives you certain additional
25 ** rights. These rights are described in the Digia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ****************************************************************************/
29 
30 #ifndef HOSTOSINFO_H
31 #define HOSTOSINFO_H
32 
33 #include "utils_global.h"
34 
35 #include <QString>
36 
37 #ifdef Q_OS_WIN
38 #define QTC_HOST_EXE_SUFFIX ".exe"
39 #else
40 #define QTC_HOST_EXE_SUFFIX ""
41 #endif // Q_OS_WIN
42 
43 namespace Utils {
44 
45 class QTCREATOR_UTILS_EXPORT HostOsInfo
46 {
47 public:
48  // Add more as needed.
49  enum HostOs { HostOsWindows, HostOsLinux, HostOsMac, HostOsOtherUnix, HostOsOther };
50  static inline HostOs hostOs();
51 
52  enum HostArchitecture { HostArchitectureX86, HostArchitectureAMD64, HostArchitectureItanium,
53  HostArchitectureArm, HostArchitectureUnknown };
54  static HostArchitecture hostArchitecture();
55 
56  static bool isWindowsHost() { return hostOs() == HostOsWindows; }
57  static bool isLinuxHost() { return hostOs() == HostOsLinux; }
58  static bool isMacHost() { return hostOs() == HostOsMac; }
59  static inline bool isAnyUnixHost();
60 
61  static QString appendExecutableSuffix(const QString &executable)
62  {
63  QString finalName = executable;
64  if (isWindowsHost())
65  finalName += QLatin1String(QTC_HOST_EXE_SUFFIX);
66  return finalName;
67  }
68 
69  static Qt::CaseSensitivity fileNameCaseSensitivity()
70  {
71  return isWindowsHost() ? Qt::CaseInsensitive: Qt::CaseSensitive;
72  }
73 
74  static QChar pathListSeparator()
75  {
76  return isWindowsHost() ? QLatin1Char(';') : QLatin1Char(':');
77  }
78 
79  static Qt::KeyboardModifier controlModifier()
80  {
81  return isMacHost() ? Qt::MetaModifier : Qt::ControlModifier;
82  }
83 
88  static bool debuggerPresent();
89 };
90 
92 {
93 #if defined(Q_OS_WIN)
94  return HostOsWindows;
95 #elif defined(Q_OS_LINUX)
96  return HostOsLinux;
97 #elif defined(Q_OS_MAC)
98  return HostOsMac;
99 #elif defined(Q_OS_UNIX)
100  return HostOsOtherUnix;
101 #else
102  return HostOsOther;
103 #endif
104 }
105 
107 {
108 #ifdef Q_OS_UNIX
109  return true;
110 #else
111  return false;
112 #endif
113 }
114 
115 } // namespace Utils
116 
117 #endif // HOSTOSINFO_H
static QString appendExecutableSuffix(const QString &executable)
Definition: hostosinfo.h:61
static Qt::KeyboardModifier controlModifier()
Definition: hostosinfo.h:79
static Qt::CaseSensitivity fileNameCaseSensitivity()
Definition: hostosinfo.h:69
static HostOs hostOs()
Definition: hostosinfo.h:91
static bool isAnyUnixHost()
Definition: hostosinfo.h:106
static bool isMacHost()
Definition: hostosinfo.h:58
static QChar pathListSeparator()
Definition: hostosinfo.h:74
static bool isLinuxHost()
Definition: hostosinfo.h:57
static bool isWindowsHost()
Definition: hostosinfo.h:56