QOpcUaExtensionObject Class | Qt OPC UA 6.4.1

- Qt 6.4
- Qt OPC UA
- C++ Classes
- QOpcUaExtensionObject
- Qt 6.4.1 Reference Documentation

# QOpcUaExtensionObject Class

The OPC UA ExtensionObject. More...

Header: | #include <QOpcUaExtensionObject>
CMake: | find_package(Qt6 REQUIRED COMPONENTS OpcUa) target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: | QT += opcua

- List of all members, including inherited members

## Public Types

enum | Encoding { NoBody, ByteString, Xml }

## Public Functions

| QOpcUaExtensionObject(const QOpcUaExtensionObject &rhs)
QOpcUaExtensionObject & | operator=(const QOpcUaExtensionObject &rhs)
QByteArray | encodedBody() const
QByteArray & | encodedBodyRef()
QOpcUaExtensionObject::Encoding | encoding() const
QString | encodingTypeId() const
void | setBinaryEncodedBody(const QByteArray &encodedBody, const QString &typeId)
void | setEncodedBody(const QByteArray &encodedBody)
void | setEncoding(QOpcUaExtensionObject::Encoding encoding)
void | setEncodingTypeId(const QString &encodingTypeId)
void | setXmlEncodedBody(const QByteArray &encodedBody, const QString &typeId)
QVariant | operator QVariant() const
bool | operator==(const QOpcUaExtensionObject &rhs) const

## Detailed Description

This is the Qt OPC UA representation for an extension object. Extension objects are used as a container in OPC UA whenever a non-builtin type is stored in a Variant. It contains information about the type and encoding of the data as well as the data itself encoded with one of the encodings specified in OPC-UA part 6. Decoders are supposed to decode extension objects if they can handle the type. If the type is not supported by the decoder, the extension object is not decoded and decoding is left to the user.

## Member Type Documentation

### enum QOpcUaExtensionObject::Encoding

Enumerates the possible encodings of the body.

Constant | Value
--- | ---
`QOpcUaExtensionObject::NoBody` | `0`
`QOpcUaExtensionObject::ByteString` | `1`
`QOpcUaExtensionObject::Xml` | `2`

## Member Function Documentation

### QOpcUaExtensionObject::QOpcUaExtensionObject(const QOpcUaExtensionObject &rhs)

Constructs an extension object from rhs.

### QOpcUaExtensionObject &QOpcUaExtensionObject::operator=(const QOpcUaExtensionObject &rhs)

Sets the values from rhs in this extension object.

### QByteArray QOpcUaExtensionObject::encodedBody() const

Returns the body of this extension object. It contains the encoded data.

See also setEncodedBody().

### QByteArray &QOpcUaExtensionObject::encodedBodyRef()

Returns a reference to the body of this extension object.

### QOpcUaExtensionObject::Encoding QOpcUaExtensionObject::encoding() const

Returns the encoding of the body.

See also setEncoding().

### QString QOpcUaExtensionObject::encodingTypeId() const

Returns the node id of the encoding for the type stored by this extension object, for example ns=0;i=886 for Range_Encoding_DefaultBinary. All encoding ids are listed in https://opcfoundation.org/UA/schemas/1.03/NodeIds.csv.

See also setEncodingTypeId().

### `[since 5.13]` void QOpcUaExtensionObject::setBinaryEncodedBody(const QByteArray &encodedBody, const QString &typeId)

Sets the body of this extension object to encodedBody, sets the encoding of the body to ByteString and sets the type id of the encoded data to typeId.

This function was introduced in Qt 5.13.

See also setEncodedBody(), setEncoding(), and setEncodingTypeId().

### void QOpcUaExtensionObject::setEncodedBody(const QByteArray &encodedBody)

Sets the body of this extension object to encodedBody.

See also encodedBody().

### void QOpcUaExtensionObject::setEncoding(QOpcUaExtensionObject::Encoding encoding)

Sets the encoding of the body to encoding.

See also encoding().

### void QOpcUaExtensionObject::setEncodingTypeId(const QString &encodingTypeId)

Sets the node id of the encoding for the type stored by this extension object to encodingTypeId.

See also encodingTypeId().

### `[since 5.13]` void QOpcUaExtensionObject::setXmlEncodedBody(const QByteArray &encodedBody, const QString &typeId)

Sets the body of this extension object to encodedBody, sets the encoding of the body to Xml and sets the type id of the encoded data to typeId.

This function was introduced in Qt 5.13.

See also setEncodedBody(), setEncoding(), and setEncodingTypeId().

### QVariant QOpcUaExtensionObject::operator QVariant() const

Converts this extension object to QVariant.

### bool QOpcUaExtensionObject::operator==(const QOpcUaExtensionObject &rhs) const

Returns `true` if this extension object has the same value as rhs.