open62541pp 0.18.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
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 2094 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< T >
constexpr Wrapper () noexcept=default
 
constexpr Wrapper (const T &native) noexcept
 
constexpr Wrapper (T &&native) noexcept
 
constexpr Wrapperoperator= (const T &native) noexcept
 
constexpr Wrapperoperator= (T &&native) noexcept
 
constexpr operator T& () noexcept
 
constexpr operator const T & () const noexcept
 
constexpr T * operator-> () noexcept
 
constexpr const T * operator-> () const noexcept
 
constexpr T * handle () noexcept
 
constexpr const T * handle () const noexcept
 
constexpr void swap (Wrapper &other) noexcept
 
constexpr void swap (T &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< T >
using NativeType = T
 
- Protected Member Functions inherited from opcua::TypeWrapper< UA_ExtensionObject, UA_TYPES_EXTENSIONOBJECT >
constexpr void clear () noexcept
 
- Protected Member Functions inherited from opcua::Wrapper< T >
constexpr const T & native () const noexcept
 
constexpr T & native () 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 2110 of file types.hpp.

◆ 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 2120 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 2135 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 2144 of file types.hpp.

Member Function Documentation

◆ fromDecoded()

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

Definition at line 2155 of file types.hpp.

◆ fromDecodedCopy()

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

Definition at line 2162 of file types.hpp.

◆ empty()

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

Check if the ExtensionObject is empty.

Definition at line 2167 of file types.hpp.

Referenced by isEmpty().

◆ isEmpty()

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

Definition at line 2173 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 2178 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 2184 of file types.hpp.

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

◆ encoding()

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

Get the encoding.

Definition at line 2190 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 2196 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 2202 of file types.hpp.

Referenced by getEncodedTypeId().

◆ getEncodedTypeId()

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

Definition at line 2210 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 2216 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 2224 of file types.hpp.

◆ getEncodedBody()

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

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

Referenced by getDecodedDataType().

◆ getDecodedDataType()

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

Definition at line 2248 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 2256 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 2264 of file types.hpp.

◆ getDecodedData() [1/4]

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

Definition at line 2271 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 2278 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 2285 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 2294 of file types.hpp.

◆ getDecodedData() [3/4]

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

Definition at line 2302 of file types.hpp.

◆ getDecodedData() [4/4]

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

Definition at line 2308 of file types.hpp.

◆ TypeWrapper() [1/5]

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

◆ TypeWrapper() [2/5]

constexpr 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]

constexpr 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]

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

Copy constructor (deep copy).

Definition at line 43 of file typewrapper.hpp.

◆ TypeWrapper() [5/5]

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

Move constructor.

Definition at line 47 of file typewrapper.hpp.