QtBase  v6.3.1
cxx11-enums.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Olivier Goffart.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef CXX11_ENUMS_H
30 #define CXX11_ENUMS_H
31 #include <QtCore/QObject>
32 
34 {
35  Q_GADGET
36 public:
37  enum class EnumClass { A0, A1, A2, A3 };
38  enum TypedEnum : char { B0, B1 , B2, B3 };
39  enum class TypedEnumClass : char { C0, C1, C2, C3 };
40  enum NormalEnum { D2 = 2, D3, D0 =0 , D1 };
41  enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8};
42 
43  enum struct EnumStruct { G0, G1, G2, G3 };
44  enum struct TypedEnumStruct : char { H0, H1, H2, H3 };
45  enum struct StructFlag { I0 = 1, I1 = 2, I2 = 4, I3 = 8};
46 
47  Q_DECLARE_FLAGS(ClassFlags, ClassFlag)
48  Q_DECLARE_FLAGS(StructFlags, StructFlag)
49 
56  Q_FLAG(ClassFlags)
57  Q_FLAG(StructFlags)
58 };
59 
60 // Also test the Q_ENUMS macro
62 {
63  Q_GADGET
64 public:
65  enum class EnumClass { A0, A1, A2, A3 };
66  enum TypedEnum : char { B0, B1 , B2, B3 };
67  enum class TypedEnumClass : char { C0, C1, C2, C3 };
68  enum NormalEnum { D2 = 2, D3, D0 =0 , D1 };
69  enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8 };
70  Q_DECLARE_FLAGS(ClassFlags, ClassFlag)
72  Q_FLAGS(ClassFlags)
73 };
74 
75 #endif // CXX11_ENUMS_H
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition: qflags.h:210
#define Q_ENUM(x)
Definition: qtmetamacros.h:104
#define Q_FLAG(x)
Definition: qtmetamacros.h:105
#define Q_FLAGS(x)
Definition: qtmetamacros.h:100
#define Q_GADGET
Definition: qtmetamacros.h:193
#define Q_ENUMS(x)
Definition: qtmetamacros.h:99