QOpcUaGenericStructValue Class

Holds the value of a generic OPC UA structured type. 更多...

头: #include <QOpcUaGenericStructValue>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
Since: Qt 6.7

公共函数

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= (const QOpcUaGenericStructValue & rhs )
QOpcUaGenericStructValue & operator= (QOpcUaGenericStructValue && other )
bool operator!= (const QOpcUaGenericStructValue & lhs , const QOpcUaGenericStructValue & rhs )
QDebug operator<< (QDebug debug , const QOpcUaGenericStructValue & s )
bool operator== (const QOpcUaGenericStructValue & lhs , const QOpcUaGenericStructValue & rhs )

详细描述

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.

范例:

// 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";
					

成员函数文档编制

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 .

注意: 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.

另请参阅 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 .

另请参阅 fields ().

void QOpcUaGenericStructValue:: setStructureDefinition (const QOpcUaStructureDefinition & structureDefinition )

Sets the structure definition for this generic struct value to structureDefinition .

另请参阅 structureDefinition ().

void QOpcUaGenericStructValue:: setTypeId (const QString & typeId )

Sets the type node id for this generic struct value to typeId .

另请参阅 typeId ().

void QOpcUaGenericStructValue:: setTypeName (const QString & typeName )

Sets the type name for this generic struct value to typeName .

另请参阅 typeName ().

QOpcUaStructureDefinition QOpcUaGenericStructValue:: structureDefinition () const

Returns the structure definition for this generic struct value.

另请参阅 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.

另请参阅 setTypeId ().

QString QOpcUaGenericStructValue:: typeName () const

Returns the type name for this generic struct value.

另请参阅 setTypeName ().

QVariant QOpcUaGenericStructValue:: operator QVariant () const

返回 QVariant containing this generic struct value.

QOpcUaGenericStructValue &QOpcUaGenericStructValue:: operator= (const QOpcUaGenericStructValue & rhs )

设置值为 rhs in this generic struct value.

[noexcept] QOpcUaGenericStructValue &QOpcUaGenericStructValue:: operator= ( QOpcUaGenericStructValue && other )

移动赋值 other 到此 QOpcUaGenericStructValue 实例。

注意: 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] bool operator!= (const QOpcUaGenericStructValue & lhs , const QOpcUaGenericStructValue & rhs )

返回 true if lhs 不等于 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 )

返回 true if lhs 等于 rhs .