1 | // Copyright (C) 2023 basysKom GmbH, opensource@basyskom.com |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "field.h" |
5 | #include "structuredtype.h" |
6 | #include "visitor.h" |
7 | |
8 | #include <QtCore/qdebug.h> |
9 | |
10 | StructuredType::StructuredType(const QString &name, const QString &baseType) |
11 | : XmlElement(name) |
12 | , m_baseType(baseType) |
13 | {} |
14 | |
15 | StructuredType::~StructuredType() |
16 | { |
17 | qDeleteAll(c: m_fields); |
18 | } |
19 | |
20 | QString StructuredType::baseType() const |
21 | { |
22 | return m_baseType; |
23 | } |
24 | |
25 | void StructuredType::setBaseType(const QString &baseType) |
26 | { |
27 | m_baseType = baseType; |
28 | } |
29 | |
30 | void StructuredType::addField(Field *field) |
31 | { |
32 | m_fields.push_back(t: field); |
33 | } |
34 | |
35 | void StructuredType::print() const |
36 | { |
37 | XmlElement::print(); |
38 | qDebug() << "BaseType: "<< m_baseType; |
39 | for (int i = 0; i < m_fields.size(); i++) |
40 | m_fields.at(i)->print(); |
41 | } |
42 | |
43 | void StructuredType::accept(Visitor *visitor) |
44 | { |
45 | visitor->visit(structuredType: this); |
46 | for (const auto &field : m_fields) |
47 | field->accept(visitor); |
48 | } |
49 | |
50 | QList<Field *> StructuredType::fields() const |
51 | { |
52 | return m_fields; |
53 | } |
54 | |
55 | void StructuredType::setFields(const QList<Field *> &fields) |
56 | { |
57 | m_fields = fields; |
58 | } |
59 | |
60 | bool StructuredType::containsBitMask() const |
61 | { |
62 | return m_containsBitMask; |
63 | } |
64 | |
65 | void StructuredType::setContainsBitMask(bool containsBitMask) |
66 | { |
67 | m_containsBitMask = containsBitMask; |
68 | } |
69 | |
70 | bool StructuredType::isBuiltInType() const |
71 | { |
72 | return m_isBuiltInType; |
73 | } |
74 | |
75 | void StructuredType::setIsBuiltInType(bool isBuiltInType) |
76 | { |
77 | m_isBuiltInType = isBuiltInType; |
78 | } |
79 | |
80 | bool StructuredType::hasSwitchfield() const |
81 | { |
82 | return m_hasSwitchfield; |
83 | } |
84 | |
85 | void StructuredType::setHasSwitchfield(bool hasSwitchfield) |
86 | { |
87 | m_hasSwitchfield = hasSwitchfield; |
88 | } |
89 | |
90 | bool StructuredType::hasUnion() const |
91 | { |
92 | return m_hasUnion; |
93 | } |
94 | |
95 | void StructuredType::setHasUnion(bool hasUnion) |
96 | { |
97 | m_hasUnion = hasUnion; |
98 | } |
99 | |
100 | QString StructuredType::targetNamespace() const |
101 | { |
102 | return m_targetNamespace; |
103 | } |
104 | |
105 | void StructuredType::setTargetNamespace(const QString &targetNamespace) |
106 | { |
107 | m_targetNamespace = targetNamespace; |
108 | } |
109 | |
110 | bool StructuredType::recursive() const |
111 | { |
112 | return m_recursive; |
113 | } |
114 | |
115 | void StructuredType::setRecursive(bool recursive) |
116 | { |
117 | m_recursive = recursive; |
118 | } |
119 |