QOpcUaBinaryDataEncoding Class

QOpcUaBinaryDataEncoding is a partial implementation of the OPC UA binary data encoding described in OPC-UA part 6. More...

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

Public Functions

QOpcUaBinaryDataEncoding(QByteArray *buffer)
QOpcUaBinaryDataEncoding(QOpcUaExtensionObject &object)
T decode(bool &success)
QList<T> decodeArray(bool &success)
bool encode(const T &src)
bool encodeArray(const QList<T> &src)
int offset() const
void setOffset(int offset)
void truncateBufferToOffset()

Detailed Description

It offers template functions for encoding and decoding data for reading and writing extension objects.

The following types are supported:

Qt typeOPC UA type
quint8uint8
qint8int8
quint16uint16
qint16int16
quint32uint32
qint32int32
quint64uint64
qint64int64
floatfloat
doubledouble
QStringString
QOpcUaQualifiedNameQualifiedName
QOpcUaLocalizedTextLocalizedText
QOpcUaEUInformationEUInformation
QOpcUaRangeRange
QOpcUaComplexNumberComplexNumber
QOpcUaDoubleComplexNumberDoubleComplexNumber
QOpcUaAxisInformationAxisInformation
QOpcUaXValueXV
QUuidGUID
QString node idNodeId
QByteArrayByteString
QDateTimeDateTime
QOpcUa::UaStatusCodeStatusCode
QOpcUaExpandedNodeIdExpandedNodeId
QOpcUaExtensionObjectExtensionObject
QOpcUaArgumentArgument
QOpcUaApplicationRecordDataTypeApplicationRecordDataType

Member Function Documentation

QOpcUaBinaryDataEncoding::QOpcUaBinaryDataEncoding(QByteArray *buffer)

Constructs a binary data encoding object for the data buffer buffer. buffer must not be deleted as long as this binary data encoding object is used.

QOpcUaBinaryDataEncoding::QOpcUaBinaryDataEncoding(QOpcUaExtensionObject &object)

Constructs a binary data encoding object using the encoded body of object as data buffer.

object must not be deleted as long as this binary data encoding object is used.

template <typename T, QOpcUa::Types OVERLAY> T QOpcUaBinaryDataEncoding::decode(bool &success)

Decodes a scalar value of type T from the data buffer. success is set to true if the decoding was successful, false if not.

The decoded value is returned. If success is false, the returned value is invalid.

See also decodeArray().

template <typename T, QOpcUa::Types OVERLAY> QList<T> QOpcUaBinaryDataEncoding::decodeArray(bool &success)

Decodes an array of type T from the data buffer. success is set to true if the decoding was successful, false if not.

The decoded value is returned. If success is false, the returned value is invalid.

See also decode().

template <typename T, QOpcUa::Types OVERLAY> bool QOpcUaBinaryDataEncoding::encode(const T &src)

Encodes src of type T and appends the encoded value to the data buffer. Returns true if the value has been successfully encoded.

See also encodeArray().

template <typename T, QOpcUa::Types OVERLAY> bool QOpcUaBinaryDataEncoding::encodeArray(const QList<T> &src)

Encodes all elements of type T in src and appends the encoded values to the data buffer.

Returns true if the value has been successfully encoded.

See also encode().

int QOpcUaBinaryDataEncoding::offset() const

Returns the current offset in the data buffer.

See also setOffset().

void QOpcUaBinaryDataEncoding::setOffset(int offset)

Sets the current offset in the data buffer to offset. The first byte in the buffer has the offset 0.

See also offset().

void QOpcUaBinaryDataEncoding::truncateBufferToOffset()

Truncates the data buffer to the current offset(). If the offset is behind the current buffer size, this method does nothing.

This method can be used to roll back after an unsuccessful encode by setting the old offset and calling truncateBufferToOffset().

© 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.