From f763ed60717589ac4dc23f631b2153c3d66e5287 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 18 Jul 2019 14:25:33 +0200 Subject: Add convenience function to set body and encoding type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I27d65453a5ffdd110b153c12fb69d279a4ea6178 Reviewed-by: Jannis Völker --- src/opcua/client/qopcuaextensionobject.cpp | 32 ++++++++++++++++++++++++++++++ src/opcua/client/qopcuaextensionobject.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/src/opcua/client/qopcuaextensionobject.cpp b/src/opcua/client/qopcuaextensionobject.cpp index fce6ab7..cb2d884 100644 --- a/src/opcua/client/qopcuaextensionobject.cpp +++ b/src/opcua/client/qopcuaextensionobject.cpp @@ -155,6 +155,38 @@ void QOpcUaExtensionObject::setEncodedBody(const QByteArray &encodedBody) data->encodedBody = encodedBody; } +/*! + \since 5.13 + + Sets the body of this extension object to \a encodedBody, + sets the encoding of the body to \l Encoding::ByteString and + sets the type id of the encoded data to \a typeId. + + \sa setEncodedBody() setEncoding() setEncodingTypeId() +*/ +void QOpcUaExtensionObject::setBinaryEncodedBody(const QByteArray &encodedBody, const QString &typeId) +{ + setEncodedBody(encodedBody); + setEncoding(Encoding::ByteString); + setEncodingTypeId(typeId); +} + +/*! + \since 5.13 + + Sets the body of this extension object to \a encodedBody, + sets the encoding of the body to \l Encoding::Xml and + sets the type id of the encoded data to \a typeId. + + \sa setEncodedBody() setEncoding() setEncodingTypeId() +*/ +void QOpcUaExtensionObject::setXmlEncodedBody(const QByteArray &encodedBody, const QString &typeId) +{ + setEncodedBody(encodedBody); + setEncoding(Encoding::Xml); + setEncodingTypeId(typeId); +} + /*! 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 \l {https://opcfoundation.org/UA/schemas/1.03/NodeIds.csv}. diff --git a/src/opcua/client/qopcuaextensionobject.h b/src/opcua/client/qopcuaextensionobject.h index 2d4a000..57b3e75 100644 --- a/src/opcua/client/qopcuaextensionobject.h +++ b/src/opcua/client/qopcuaextensionobject.h @@ -68,6 +68,9 @@ public: QByteArray &encodedBodyRef(); void setEncodedBody(const QByteArray &encodedBody); + void setBinaryEncodedBody(const QByteArray &encodedBody, const QString &typeId); + void setXmlEncodedBody(const QByteArray &encodedBody, const QString &typeId); + QOpcUaExtensionObject::Encoding encoding() const; void setEncoding(QOpcUaExtensionObject::Encoding encoding); -- cgit v1.2.3