QOpcUaGenericStructValue Class
Holds the value of a generic OPC UA structured type. More...
Header: | #include <QOpcUaGenericStructValue> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS OpcUa) target_link_libraries(mytarget PRIVATE Qt6::OpcUa) |
qmake: | QT += opcua |
Since: | Qt 6.7 |
Public Functions
QOpcUaGenericStructValue() | |
QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition) | |
QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition, const QHash<QString, QVariant> &fields) | |
QOpcUaGenericStructValue(const QOpcUaGenericStructValue &other) | |
QOpcUaGenericStructValue(QOpcUaGenericStructValue &&other) | |
~QOpcUaGenericStructValue() | |
QHash<QString, QVariant> | fields() const |
QHash<QString, QVariant> & | fieldsRef() |
void | setFields(const QHash<QString, QVariant> &fields) |
void | setStructureDefinition(const QOpcUaStructureDefinition &structureDefinition) |
void | setTypeId(const QString &typeId) |
void | setTypeName(const QString &typeName) |
QOpcUaStructureDefinition | structureDefinition() const |
void | swap(QOpcUaGenericStructValue &other) |
QString | toString() const |
QString | typeId() const |
QString | typeName() const |
QVariant | operator QVariant() const |
QOpcUaGenericStructValue & | operator=(QOpcUaGenericStructValue &&other) |
QOpcUaGenericStructValue & | operator=(const QOpcUaGenericStructValue &rhs) |
Related Non-Members
bool | operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs) |
QDebug | operator<<(QDebug debug, const QOpcUaGenericStructValue &s) |
bool | operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs) |
Detailed Description
This class holds a generic OPC UA struct value which consists of named fields with their values which can be built-in types or their sub types as well as other nested generic structs. Some meta information like the type ID and the structure definition of the type contained in an object of this class is also included.
It is used as return type for the decoding result and as input type for the encoding method of QOpcUaGenericStructHandler.
For a struct with optional fields, only the fields that were specified are contained in the fields() list. To omit an optional field during encoding, it must not appear in the fields() list. For structs derived from the Union type, only one of the fields must be specified. The only entry in the fields() list of a decoded type determines which field (if any) of the type definition was specified.
Example:
// Decode an extension object QOpcUaGenericStructValue value = decoder.decode(extensionObject, success); // Print the value of a mandatory field qDebug() << value.fields().value("MyField").value<QOpcUaLocalizedText>(); // Print the value of an optional field if (value.fields().contains("MyOptionalField")) qDebug() << value.fields().value("MyField").value<QOpcUaQualifiedName>(); // Get a nested struct for a field const auto unionMember = value.fields().value("MyUnionMember").value<QOpcUaGenericStructValue>(); // Print the specified field if (unionMember.fields().contains("UnionMember1")) qDebug() << unionMember.fields().value("UnionMember1").toInt(); else if (unionMember.fields().contains("UnionMember2")) qDebug() << unionMember.fields().value("UnionMember2").toDouble(); else qDebug() << "Empty union";
Member Function Documentation
QOpcUaGenericStructValue::QOpcUaGenericStructValue()
Constructs a generic struct value.
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition)
Constructs a generic struct value from typeName, typeId and definition.
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QString &typeName, const QString &typeId, const QOpcUaStructureDefinition &definition, const QHash<QString, QVariant> &fields)
Constructs a generic struct value from typeName, typeId, definition and fields.
QOpcUaGenericStructValue::QOpcUaGenericStructValue(const QOpcUaGenericStructValue &other)
Constructs a generic struct value from other.
[noexcept]
QOpcUaGenericStructValue::QOpcUaGenericStructValue(QOpcUaGenericStructValue &&other)
Move-constructs a new generic struct value from other.
Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.
[noexcept]
QOpcUaGenericStructValue::~QOpcUaGenericStructValue()
Destroys this generic struct value object.
QHash<QString, QVariant> QOpcUaGenericStructValue::fields() const
Returns the fields of this generic struct value.
See also setFields().
QHash<QString, QVariant> &QOpcUaGenericStructValue::fieldsRef()
Returns a reference to the fields of this generic struct value.
void QOpcUaGenericStructValue::setFields(const QHash<QString, QVariant> &fields)
Sets the fields of this generic struct value to fields.
See also fields().
void QOpcUaGenericStructValue::setStructureDefinition(const QOpcUaStructureDefinition &structureDefinition)
Sets the structure definition for this generic struct value to structureDefinition.
See also structureDefinition().
void QOpcUaGenericStructValue::setTypeId(const QString &typeId)
Sets the type node id for this generic struct value to typeId.
See also typeId().
void QOpcUaGenericStructValue::setTypeName(const QString &typeName)
Sets the type name for this generic struct value to typeName.
See also typeName().
QOpcUaStructureDefinition QOpcUaGenericStructValue::structureDefinition() const
Returns the structure definition for this generic struct value.
See also setStructureDefinition().
[noexcept]
void QOpcUaGenericStructValue::swap(QOpcUaGenericStructValue &other)
Swaps generic struct value object other with this generic struct value object. This operation is very fast and never fails.
QString QOpcUaGenericStructValue::toString() const
Returns a string representation for this generic struct value.
QString QOpcUaGenericStructValue::typeId() const
Returns the type node id for this generic struct value.
See also setTypeId().
QString QOpcUaGenericStructValue::typeName() const
Returns the type name for this generic struct value.
See also setTypeName().
QVariant QOpcUaGenericStructValue::operator QVariant() const
Returns a QVariant containing this generic struct value.
[noexcept]
QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(QOpcUaGenericStructValue &&other)
Move-assigns other to this QOpcUaGenericStructValue instance.
Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.
QOpcUaGenericStructValue &QOpcUaGenericStructValue::operator=(const QOpcUaGenericStructValue &rhs)
Sets the value of rhs in this generic struct value.
Related Non-Members
[noexcept]
bool operator!=(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
Returns true
if lhs is not equal to rhs.
QDebug operator<<(QDebug debug, const QOpcUaGenericStructValue &s)
Outputs the string representation of s into debug.
[noexcept]
bool operator==(const QOpcUaGenericStructValue &lhs, const QOpcUaGenericStructValue &rhs)
Returns true
if lhs is equal to rhs.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.