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 "visitor.h"
6
7#include <QtCore/qdebug.h>
8#include <QtCore/qstringlist.h>
9
10using namespace Qt::Literals::StringLiterals;
11
12Field::Field(const QString &name, const QString &typeName, const QString &lengthField)
13 : XmlElement(name)
14 , m_lengthField(lengthField)
15 , m_typeName(typeName)
16{}
17
18QString Field::typeName() const
19{
20 return m_typeName;
21}
22
23QString Field::typeNameSecondPart() const
24{
25 return m_typeName.split(sep: ':'_L1).value(i: 1, defaultValue: QString());
26}
27
28void Field::setTypeName(const QString &typeName)
29{
30 m_typeName = typeName;
31}
32
33QString Field::lengthField() const
34{
35 return m_lengthField;
36}
37
38void Field::setLengthField(const QString &lengthField)
39{
40 m_lengthField = lengthField;
41}
42
43bool Field::hasLengthField() const
44{
45 return m_hasLengthField;
46}
47
48void Field::setHasLengthField(bool hasLengthField)
49{
50 m_hasLengthField = hasLengthField;
51}
52
53bool Field::needContainer() const
54{
55 return m_needContainer;
56}
57
58void Field::setNeedContainer(bool needContainer)
59{
60 m_needContainer = needContainer;
61}
62
63bool Field::isInStructuredTypeBitMask() const
64{
65 return m_isInStructuredTypeBitMask;
66}
67
68void Field::setIsInStructuredTypeBitMask(bool isInStructuredTypeBitMask)
69{
70 m_isInStructuredTypeBitMask = isInStructuredTypeBitMask;
71}
72
73int Field::length() const
74{
75 return m_length;
76}
77
78void Field::setLength(int length)
79{
80 m_length = length;
81}
82
83QString Field::switchField() const
84{
85 return m_switchField;
86}
87
88void Field::setSwitchField(const QString &switchField)
89{
90 m_switchField = switchField;
91}
92
93int Field::switchValue() const
94{
95 return m_switchValue;
96}
97
98void Field::setSwitchValue(int switchValue)
99{
100 m_switchValue = switchValue;
101}
102
103bool Field::isUnion() const
104{
105 return m_isUnion;
106}
107
108void Field::setIsUnion(bool isUnion)
109{
110 m_isUnion = isUnion;
111}
112
113bool Field::recursive() const
114{
115 return m_recursive;
116}
117
118void Field::setRecursive(bool recursive)
119{
120 m_recursive = recursive;
121}
122
123bool Field::isEnum() const
124{
125 return m_isEnum;
126}
127
128void Field::setIsEnum(bool newIsEnum)
129{
130 m_isEnum = newIsEnum;
131}
132
133void Field::print() const
134{
135 XmlElement::print();
136 qDebug() << "Type name: " << m_typeName;
137 if (!m_lengthField.isEmpty())
138 qDebug() << "Length field: " << m_lengthField;
139}
140
141void Field::accept(Visitor *visitor)
142{
143 visitor->visit(field: this);
144}
145

source code of qtopcua/tools/datatypecodegenerator/field.cpp