| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef ENUMNODE_H |
| 5 | #define ENUMNODE_H |
| 6 | |
| 7 | #include "access.h" |
| 8 | #include "genustypes.h" |
| 9 | #include "node.h" |
| 10 | #include "typedefnode.h" |
| 11 | |
| 12 | #include <QtCore/qglobal.h> |
| 13 | #include <QtCore/qlist.h> |
| 14 | #include <QtCore/qset.h> |
| 15 | #include <QtCore/qstring.h> |
| 16 | |
| 17 | QT_BEGIN_NAMESPACE |
| 18 | |
| 19 | class Aggregate; |
| 20 | |
| 21 | class EnumNode : public Node |
| 22 | { |
| 23 | public: |
| 24 | using Node::Node; |
| 25 | EnumNode(Aggregate *parent, const QString &name, bool isScoped = false) |
| 26 | : Node(NodeType::Enum, parent, name), m_isScoped(isScoped) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | void addItem(const EnumItem &item); |
| 31 | void setFlagsType(TypedefNode *typedefNode); |
| 32 | bool hasItem(const QString &name) const { return m_names.contains(value: name); } |
| 33 | bool isScoped() const { return m_isScoped; } |
| 34 | bool isAnonymous() const { return m_isAnonymous; } |
| 35 | |
| 36 | const QList<EnumItem> &items() const { return m_items; } |
| 37 | Access itemAccess(const QString &name) const; |
| 38 | const TypedefNode *flagsType() const { return m_flagsType; } |
| 39 | QString itemValue(const QString &name) const; |
| 40 | Node *clone(Aggregate *parent) override; |
| 41 | void setAnonymous(bool anonymous) { m_isAnonymous = anonymous; } |
| 42 | void setSince(const QString &value, const QString &since); |
| 43 | |
| 44 | private: |
| 45 | QList<EnumItem> m_items {}; |
| 46 | QSet<QString> m_names {}; |
| 47 | const TypedefNode *m_flagsType { nullptr }; |
| 48 | bool m_isAnonymous { false }; |
| 49 | bool m_isScoped { false }; |
| 50 | }; |
| 51 | |
| 52 | QT_END_NAMESPACE |
| 53 | |
| 54 | #endif // ENUMNODE_H |
| 55 |
