open62541pp 0.16.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 1664 of file types.hpp.

Public Member Functions

bool isEmpty () const noexcept
 
bool isEncoded () const noexcept
 
bool isDecoded () const noexcept
 
ExtensionObjectEncoding getEncoding () const noexcept
 
const NodeIdgetEncodedTypeId () const noexcept
 
const ByteStringgetEncodedBody () const noexcept
 
const UA_DataTypegetDecodedDataType () const noexcept
 
template<typename T >
T * getDecodedData () noexcept
 
template<typename T >
const T * getDecodedData () const noexcept
 
void * getDecodedData () noexcept
 
const void * getDecodedData () const noexcept
 
constexpr TypeWrapper ()=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 ()=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
 
constexpr void swap (TypeWrapper &other) noexcept
 
constexpr void swap (UA_ExtensionObject &native) noexcept
 
- Public Member Functions inherited from opcua::Wrapper< UA_ExtensionObject >
constexpr Wrapper ()=default
 
constexpr Wrapper (const UA_ExtensionObject &native)
 
constexpr Wrapper (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
 

Static Public Member Functions

template<typename T >
static ExtensionObject fromDecoded (T &data) noexcept
 
static ExtensionObject fromDecoded (void *data, const UA_DataType &type) noexcept
 
template<typename T >
static ExtensionObject fromDecodedCopy (const T &data)
 
static ExtensionObject fromDecodedCopy (const void *data, const UA_DataType &type)
 
- Static Public Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
static constexpr TypeIndex getTypeIndex ()
 

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
 

Member Function Documentation

◆ fromDecoded() [1/2]

template<typename T >
static ExtensionObject opcua::ExtensionObject::fromDecoded ( T & data)
inlinestaticnodiscardnoexcept

Create an ExtensionObject from a decoded object (reference).

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

Parameters
dataDecoded data

Definition at line 1672 of file types.hpp.

Referenced by fromDecoded(), and opcua::services::detail::wrapNodeAttributes().

◆ fromDecoded() [2/2]

static ExtensionObject opcua::ExtensionObject::fromDecoded ( void * data,
const UA_DataType & type )
inlinestaticnodiscardnoexcept

Create an ExtensionObject from a decoded object (reference).

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

Parameters
dataDecoded data
typeData type of the decoded data
Warning
Type erased version, use with caution.

Definition at line 1681 of file types.hpp.

◆ fromDecodedCopy() [1/2]

template<typename T >
static ExtensionObject opcua::ExtensionObject::fromDecodedCopy ( const T & data)
inlinestaticnodiscard

Create an ExtensionObject from a decoded object (copy).

Set the "decoded" data to a copy of the given object.

Parameters
dataDecoded data

Definition at line 1693 of file types.hpp.

Referenced by fromDecodedCopy(), and opcua::Subscription< Connection >::subscribeEvent().

◆ fromDecodedCopy() [2/2]

static ExtensionObject opcua::ExtensionObject::fromDecodedCopy ( const void * data,
const UA_DataType & type )
inlinestaticnodiscard

Create an ExtensionObject from a decoded object (copy).

Parameters
dataDecoded data
typeData type of the decoded data
Warning
Type erased version, use with caution.

Definition at line 1701 of file types.hpp.

◆ isEmpty()

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

Check if the ExtensionObject is empty.

Definition at line 1715 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 1720 of file types.hpp.

Referenced by getEncodedBody(), and getEncodedTypeId().

◆ isDecoded()

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

Check if the ExtensionObject is decoded.

Definition at line 1726 of file types.hpp.

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

◆ getEncoding()

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

Get the encoding.

Definition at line 1732 of file types.hpp.

◆ getEncodedTypeId()

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

Get the encoded type id.

Returns nullptr if ExtensionObject is not encoded.

Definition at line 1738 of file types.hpp.

◆ getEncodedBody()

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

Get the encoded body.

Returns nullptr if ExtensionObject is not encoded.

Definition at line 1746 of file types.hpp.

◆ getDecodedDataType()

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

Get the decoded data type.

Returns nullptr if ExtensionObject is not decoded.

Definition at line 1754 of file types.hpp.

◆ getDecodedData() [1/4]

template<typename T >
T * opcua::ExtensionObject::getDecodedData ( )
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 1764 of file types.hpp.

Referenced by getDecodedData(), and getDecodedData().

◆ getDecodedData() [2/4]

template<typename T >
const T * opcua::ExtensionObject::getDecodedData ( ) 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 1772 of file types.hpp.

◆ getDecodedData() [3/4]

void * opcua::ExtensionObject::getDecodedData ( )
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 1779 of file types.hpp.

◆ getDecodedData() [4/4]

const void * opcua::ExtensionObject::getDecodedData ( ) 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 1788 of file types.hpp.

◆ TypeWrapper() [1/5]

opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( )
constexprdefault

◆ TypeWrapper() [2/5]

opcua::TypeWrapper< T, typeIndex >::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, typeIndex >::TypeWrapper ( T && native)
inlineconstexprnoexcept

Constructor with native object (move rvalue).

Definition at line 35 of file typewrapper.hpp.

◆ TypeWrapper() [4/5]

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

Copy constructor (deep copy).

Definition at line 43 of file typewrapper.hpp.

◆ TypeWrapper() [5/5]

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

Move constructor.

Definition at line 47 of file typewrapper.hpp.