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
33class CXX11Enums
34{
35 Q_GADGET
36public:
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
50 Q_ENUM(EnumClass)
51 Q_ENUM(TypedEnum)
52 Q_ENUM(TypedEnumClass)
53 Q_ENUM(NormalEnum)
54 Q_ENUM(EnumStruct)
55 Q_ENUM(TypedEnumStruct)
56 Q_FLAG(ClassFlags)
57 Q_FLAG(StructFlags)
58};
59
60// Also test the Q_ENUMS macro
61class CXX11Enums2
62{
63 Q_GADGET
64public:
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)
71 Q_ENUMS(EnumClass TypedEnum TypedEnumClass NormalEnum)
72 Q_FLAGS(ClassFlags)
73};
74
75#endif // CXX11_ENUMS_H
76

source code of qtbase/tests/auto/tools/moc/cxx11-enums.h