summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2019-07-18 14:25:33 +0200
committerRainer Keller <Rainer.Keller@qt.io>2019-07-22 11:00:57 +0200
commitf763ed60717589ac4dc23f631b2153c3d66e5287 (patch)
treed58ae17369e20310c653145ce80eaef31ff07eea
parent78e32b82057b591971894a178d326e4675cd5f8b (diff)
Add convenience function to set body and encoding type
Change-Id: I27d65453a5ffdd110b153c12fb69d279a4ea6178 Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com>
-rw-r--r--src/opcua/client/qopcuaextensionobject.cpp32
-rw-r--r--src/opcua/client/qopcuaextensionobject.h3
2 files changed, 35 insertions, 0 deletions
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
@@ -156,6 +156,38 @@ void QOpcUaExtensionObject::setEncodedBody(const QByteArray &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);