open62541pp 0.17.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
opcua::ExtensionObject Class Reference

#include <types.hpp>

Inheritance diagram for opcua::ExtensionObject:
[legend]

Detailed Description

UA_ExtensionObject wrapper class.

ExtensionObjects may contain scalars of any data type. Even those that are unknown to the receiver. If the received data type is unknown, the encoded string and target NodeId is stored instead of the decoded data.

See also
https://reference.opcfoundation.org/Core/Part6/v105/docs/5.1.6
https://reference.opcfoundation.org/Core/Part6/v105/docs/5.2.2.15
Examples
custom_datatypes/client_custom_datatypes.cpp, and server_accesscontrol.cpp.

Definition at line 2077 of file types.hpp.

Public Member Functions

template<typename T >
 ExtensionObject (T *ptr) noexcept
 
template<typename T >
 ExtensionObject (T *ptr, const UA_DataType &type) noexcept
 
template<typename T , typename = std::enable_if_t<!isExtensionObject<T>>>
 ExtensionObject (const T &decoded)
 
template<typename T , typename = std::enable_if_t<!isExtensionObject<T>>>
 ExtensionObject (const T &decoded, const UA_DataType &type)
 
bool empty () const noexcept
 
bool isEmpty () const noexcept
 
bool isEncoded () const noexcept
 
bool isDecoded () const noexcept
 
ExtensionObjectEncoding encoding () const noexcept
 
ExtensionObjectEncoding getEncoding () const noexcept
 
const NodeIdencodedTypeId () const noexcept
 
const NodeIdgetEncodedTypeId () const noexcept
 
const ByteStringencodedBinary () const noexcept
 
const XmlElementencodedXml () const noexcept
 
const ByteStringgetEncodedBody () const noexcept
 
const UA_DataTypedecodedType () const noexcept
 
const UA_DataTypegetDecodedDataType () const noexcept
 
template<typename T >
T * decodedData () noexcept
 
template<typename T >
const T * decodedData () const noexcept
 
template<typename T >
T * getDecodedData () noexcept
 
template<typename T >
const T * getDecodedData () const noexcept
 
void * decodedData () noexcept
 
const void * decodedData () const noexcept
 
void * getDecodedData () noexcept
 
const void * getDecodedData () const noexcept
 
constexpr TypeWrapper () noexcept=default
 
constexpr TypeWrapper (const T &native)
 
constexpr TypeWrapper (T &&native) noexcept
 
constexpr TypeWrapper (const TypeWrapper &other)
 
constexpr TypeWrapper (TypeWrapper &&other) noexcept
 
- Public Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
constexpr TypeWrapper () noexcept=default
 
constexpr TypeWrapper (const UA_ExtensionObject &native)
 
constexpr TypeWrapper (UA_ExtensionObject &&native) noexcept
 
constexpr TypeWrapper (const TypeWrapper &other)
 
constexpr TypeWrapper (TypeWrapper &&other) noexcept
 
 ~TypeWrapper ()
 
constexpr TypeWrapperoperator= (const TypeWrapper &other)
 
constexpr TypeWrapperoperator= (const UA_ExtensionObject &native)
 
constexpr TypeWrapperoperator= (TypeWrapper &&other) noexcept
 
constexpr TypeWrapperoperator= (UA_ExtensionObject &&native) noexcept
 
- Public Member Functions inherited from opcua::Wrapper< UA_ExtensionObject >
constexpr Wrapper () noexcept=default
 
constexpr Wrapper (const UA_ExtensionObject &native) noexcept
 
constexpr Wrapper (UA_ExtensionObject &&native) noexcept
 
constexpr Wrapperoperator= (const UA_ExtensionObject &native) noexcept
 
constexpr Wrapperoperator= (UA_ExtensionObject &&native) noexcept
 
constexpr operator UA_ExtensionObject & () noexcept
 
constexpr operator const UA_ExtensionObject & () const noexcept
 
constexpr UA_ExtensionObjectoperator-> () noexcept
 
constexpr const UA_ExtensionObjectoperator-> () const noexcept
 
constexpr UA_ExtensionObjecthandle () noexcept
 
constexpr const UA_ExtensionObjecthandle () const noexcept
 
constexpr void swap (Wrapper &other) noexcept
 
constexpr void swap (UA_ExtensionObject &native) noexcept
 

Static Public Member Functions

template<typename T , typename... Args>
static ExtensionObject fromDecoded (T &data, Args &&... args) noexcept
 
template<typename T , typename... Args>
static ExtensionObject fromDecodedCopy (const T &data, Args &&... args)
 
- Static Public Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
static constexpr TypeIndex typeIndex ()
 

Additional Inherited Members

- Public Types inherited from opcua::Wrapper< UA_ExtensionObject >
using NativeType
 
- Protected Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
constexpr void clear () noexcept
 
- Protected Member Functions inherited from opcua::Wrapper< UA_ExtensionObject >
constexpr const UA_ExtensionObjectnative () const noexcept
 
constexpr UA_ExtensionObjectnative () noexcept
 

Constructor & Destructor Documentation

◆ ExtensionObject() [1/4]

template<typename T >
opcua::ExtensionObject::ExtensionObject ( T * ptr)
inlineexplicitnoexcept

Create ExtensionObject from a pointer to a decoded object (no copy).

The object will not be deleted when the ExtensionObject is destructed.

Parameters
ptrPointer to decoded object (native or wrapper).

Definition at line 2093 of file types.hpp.

Referenced by fromDecoded(), and fromDecodedCopy().

◆ ExtensionObject() [2/4]

template<typename T >
opcua::ExtensionObject::ExtensionObject ( T * ptr,
const UA_DataType & type )
inlinenoexcept

Create ExtensionObject from a pointer to a decoded object with a custom data type (no copy).

The object will not be deleted when the ExtensionObject is destructed.

Parameters
ptrPointer to decoded object (native or wrapper).
typeData type of the decoded object.

Definition at line 2103 of file types.hpp.

◆ ExtensionObject() [3/4]

template<typename T , typename = std::enable_if_t<!isExtensionObject<T>>>
opcua::ExtensionObject::ExtensionObject ( const T & decoded)
inlineexplicit

Create ExtensionObject from a decoded object (copy).

Parameters
decodedDecoded object (native or wrapper).

Definition at line 2118 of file types.hpp.

◆ ExtensionObject() [4/4]

template<typename T , typename = std::enable_if_t<!isExtensionObject<T>>>
opcua::ExtensionObject::ExtensionObject ( const T & decoded,
const UA_DataType & type )
inlineexplicit

Create ExtensionObject from a decoded object with a custom data type (copy).

Parameters
decodedDecoded object (native or wrapper).
typeData type of the decoded object.

Definition at line 2127 of file types.hpp.

Member Function Documentation

◆ fromDecoded()

template<typename T , typename... Args>
static ExtensionObject opcua::ExtensionObject::fromDecoded ( T & data,
Args &&... args )
inlinestaticnodiscardnoexcept
Deprecated
Use new universal ExtensionObject constructor instead

Definition at line 2138 of file types.hpp.

◆ fromDecodedCopy()

template<typename T , typename... Args>
static ExtensionObject opcua::ExtensionObject::fromDecodedCopy ( const T & data,
Args &&... args )
inlinestaticnodiscard
Deprecated
Use new universal ExtensionObject constructor instead

Definition at line 2145 of file types.hpp.

◆ empty()

bool opcua::ExtensionObject::empty ( ) const
inlinenoexcept

Check if the ExtensionObject is empty.

Definition at line 2150 of file types.hpp.

Referenced by isEmpty().

◆ isEmpty()

bool opcua::ExtensionObject::isEmpty ( ) const
inlinenoexcept
Deprecated
Use empty() instead

Definition at line 2156 of file types.hpp.

◆ isEncoded()

bool opcua::ExtensionObject::isEncoded ( ) const
inlinenoexcept

Check if the ExtensionObject is encoded (usually if the data type is unknown).

Definition at line 2161 of file types.hpp.

Referenced by encodedTypeId(), and getEncodedBody().

◆ isDecoded()

bool opcua::ExtensionObject::isDecoded ( ) const
inlinenoexcept

Check if the ExtensionObject is decoded.

Definition at line 2167 of file types.hpp.

Referenced by decodedData(), decodedData(), and decodedType().

◆ encoding()

ExtensionObjectEncoding opcua::ExtensionObject::encoding ( ) const
inlinenoexcept

Get the encoding.

Definition at line 2173 of file types.hpp.

Referenced by empty(), getEncoding(), isDecoded(), and isEncoded().

◆ getEncoding()

ExtensionObjectEncoding opcua::ExtensionObject::getEncoding ( ) const
inlinenoexcept
Deprecated
Use encoding() instead

Definition at line 2179 of file types.hpp.

◆ encodedTypeId()

const NodeId * opcua::ExtensionObject::encodedTypeId ( ) const
inlinenoexcept

Get the encoded type id.

Returns nullptr if ExtensionObject is not encoded.

Definition at line 2185 of file types.hpp.

Referenced by getEncodedTypeId().

◆ getEncodedTypeId()

const NodeId * opcua::ExtensionObject::getEncodedTypeId ( ) const
inlinenoexcept
Deprecated
Use encodedTypeId() instead

Definition at line 2193 of file types.hpp.

◆ encodedBinary()

const ByteString * opcua::ExtensionObject::encodedBinary ( ) const
inlinenoexcept

Get the encoded body in binary format.

Returns nullptr if ExtensionObject is not encoded in binary format.

Definition at line 2199 of file types.hpp.

◆ encodedXml()

const XmlElement * opcua::ExtensionObject::encodedXml ( ) const
inlinenoexcept

Get the encoded body in XML format.

Returns nullptr if ExtensionObject is not encoded in XML format.

Definition at line 2207 of file types.hpp.

◆ getEncodedBody()

const ByteString * opcua::ExtensionObject::getEncodedBody ( ) const
inlinenoexcept
Deprecated
Use encodedBinary() or encodedXml() instead

Definition at line 2215 of file types.hpp.

◆ decodedType()

const UA_DataType * opcua::ExtensionObject::decodedType ( ) const
inlinenoexcept

Get the decoded data type.

Returns nullptr if ExtensionObject is not decoded.

Definition at line 2223 of file types.hpp.

Referenced by getDecodedDataType().

◆ getDecodedDataType()

const UA_DataType * opcua::ExtensionObject::getDecodedDataType ( ) const
inlinenoexcept
Deprecated
Use decodedType() instead

Definition at line 2231 of file types.hpp.

◆ decodedData() [1/4]

template<typename T >
T * opcua::ExtensionObject::decodedData ( )
inlinenoexcept

Get pointer to the decoded data with given template type.

Returns nullptr if the ExtensionObject is either not decoded or the decoded data is not of type T.

Examples
server_accesscontrol.cpp.

Definition at line 2239 of file types.hpp.

Referenced by decodedData(), decodedData(), getDecodedData(), and getDecodedData().

◆ decodedData() [2/4]

template<typename T >
const T * opcua::ExtensionObject::decodedData ( ) const
inlinenoexcept

Get const pointer to the decoded data with given template type.

Returns nullptr if the ExtensionObject is either not decoded or the decoded data is not of type T.

Definition at line 2247 of file types.hpp.

◆ getDecodedData() [1/4]

template<typename T >
T * opcua::ExtensionObject::getDecodedData ( )
inlinenoexcept
Deprecated
Use decodedData<T>() instead

Definition at line 2254 of file types.hpp.

◆ getDecodedData() [2/4]

template<typename T >
const T * opcua::ExtensionObject::getDecodedData ( ) const
inlinenoexcept
Deprecated
Use decodedData<T>() instead

Definition at line 2261 of file types.hpp.

◆ decodedData() [3/4]

void * opcua::ExtensionObject::decodedData ( )
inlinenoexcept

Get pointer to the decoded data.

Returns nullptr if the ExtensionObject is not decoded.

Warning
Type erased version, use with caution.

Definition at line 2268 of file types.hpp.

◆ decodedData() [4/4]

const void * opcua::ExtensionObject::decodedData ( ) const
inlinenoexcept

Get pointer to the decoded data.

Returns nullptr if the ExtensionObject is not decoded.

Warning
Type erased version, use with caution.

Definition at line 2277 of file types.hpp.

◆ getDecodedData() [3/4]

void * opcua::ExtensionObject::getDecodedData ( )
inlinenoexcept
Deprecated
Use decodedData() instead

Definition at line 2285 of file types.hpp.

◆ getDecodedData() [4/4]

const void * opcua::ExtensionObject::getDecodedData ( ) const
inlinenoexcept
Deprecated
Use decodedData() instead

Definition at line 2291 of file types.hpp.

◆ TypeWrapper() [1/5]

opcua::TypeWrapper< T, Index >::TypeWrapper ( )
constexprdefaultnoexcept

◆ TypeWrapper() [2/5]

opcua::TypeWrapper< T, Index >::TypeWrapper ( const T & native)
inlineexplicitconstexpr

Constructor with native object (deep copy).

Definition at line 31 of file typewrapper.hpp.

◆ TypeWrapper() [3/5]

opcua::TypeWrapper< T, Index >::TypeWrapper ( T && native)
inlineconstexprnoexcept

Constructor with native object (move rvalue).

Definition at line 35 of file typewrapper.hpp.

◆ TypeWrapper() [4/5]

opcua::TypeWrapper< T, Index >::TypeWrapper ( const TypeWrapper & other)
inlineconstexpr

Copy constructor (deep copy).

Definition at line 43 of file typewrapper.hpp.

◆ TypeWrapper() [5/5]

opcua::TypeWrapper< T, Index >::TypeWrapper ( TypeWrapper && other)
inlineconstexprnoexcept

Move constructor.

Definition at line 47 of file typewrapper.hpp.