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

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

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