open62541pp 0.15.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
opcua::DataTypeBuilder< T, Tag, U > Class Template Reference

#include <datatype.hpp>

Detailed Description

template<typename T, typename Tag = detail::TagDataTypeAny, typename U = struct DeferT>
class opcua::DataTypeBuilder< T, Tag, U >

Builder to create DataType definitions of custom types.

The attributes memSize, padding, pointerFree, isArray and isOptional are automatically deduced from the types itself.

Definition at line 198 of file datatype.hpp.

Public Member Functions

template<auto U::* field>
auto & addField (const char *fieldName, const UA_DataType &fieldType)
 
template<auto U::* field>
auto & addField (const char *fieldName)
 
template<auto U::* fieldSize, auto U::* fieldArray>
auto & addField (const char *fieldName, const UA_DataType &fieldType)
 
template<auto U::* fieldSize, auto U::* fieldArray>
auto & addField (const char *fieldName)
 
template<auto U::* memberUnion, typename TField >
auto & addUnionField (const char *fieldName, const UA_DataType &fieldType)
 
template<auto U::* memberUnion, typename TField >
auto & addUnionField (const char *fieldName)
 
DataType build ()
 

Static Public Member Functions

static auto createEnum (const char *typeName, NodeId typeId, NodeId binaryEncodingId)
 
static auto createStructure (const char *typeName, NodeId typeId, NodeId binaryEncodingId)
 
static auto createUnion (const char *typeName, NodeId typeId, NodeId binaryEncodingId)
 

Friends

template<typename , typename , typename >
class DataTypeBuilder
 

Member Function Documentation

◆ createEnum()

template<typename T , typename Tag , typename U >
auto opcua::DataTypeBuilder< T, Tag, U >::createEnum ( const char * typeName,
NodeId typeId,
NodeId binaryEncodingId )
static

Build a DataType definition for an enum.

Parameters
typeNameHuman-readable type name
typeIdNodeId of the type
binaryEncodingIdNodeId of data type when encoded as binary
Examples
custom_datatypes/custom_datatypes.hpp.

Definition at line 309 of file datatype.hpp.

◆ createStructure()

template<typename T , typename Tag , typename U >
auto opcua::DataTypeBuilder< T, Tag, U >::createStructure ( const char * typeName,
NodeId typeId,
NodeId binaryEncodingId )
static

Build a DataType definition for a structure.

A structure may have optional fields (pointers).

Parameters
typeNameHuman-readable type name
typeIdNodeId of the type
binaryEncodingIdNodeId of data type when encoded as binary
Examples
custom_datatypes/custom_datatypes.hpp.

Definition at line 325 of file datatype.hpp.

◆ createUnion()

template<typename T , typename Tag , typename U >
auto opcua::DataTypeBuilder< T, Tag, U >::createUnion ( const char * typeName,
NodeId typeId,
NodeId binaryEncodingId )
static

Build a DataType definition for an union.

Union type consist of a switch field and the actual union.

Parameters
typeNameHuman-readable type name
typeIdNodeId of the type
binaryEncodingIdNodeId of data type when encoded as binary
Examples
custom_datatypes/custom_datatypes.hpp.

Definition at line 341 of file datatype.hpp.

◆ addField() [1/4]

template<typename T , typename Tag , typename U >
template<auto U::* field>
auto & opcua::DataTypeBuilder< T, Tag, U >::addField ( const char * fieldName,
const UA_DataType & fieldType )

Add a structure field.

Template Parameters
fieldMember pointer, e.g. &S::value
Parameters
fieldNameHuman-readable field name
fieldTypeMember data type

Definition at line 358 of file datatype.hpp.

Referenced by opcua::DataTypeBuilder< T, Tag, U >::addField().

◆ addField() [2/4]

template<typename T , typename Tag = detail::TagDataTypeAny, typename U = struct DeferT>
template<auto U::* field>
auto & opcua::DataTypeBuilder< T, Tag, U >::addField ( const char * fieldName)
inline

Add a structure field (derive DataType from field).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 240 of file datatype.hpp.

◆ addField() [3/4]

template<typename T , typename Tag , typename U >
template<auto U::* fieldSize, auto U::* fieldArray>
auto & opcua::DataTypeBuilder< T, Tag, U >::addField ( const char * fieldName,
const UA_DataType & fieldType )

Add a structure array field.

Arrays must consists of two fields: its size (of type size_t) and the pointer to the data. No padding allowed between the size field and the array field.

Template Parameters
fieldSizeMember pointer to the size field, e.g. &S::length
fieldArrayMember pointer to the array field, e.g. &S::data
Parameters
fieldNameHuman-readable field name
fieldTypeMember data type

Definition at line 387 of file datatype.hpp.

◆ addField() [4/4]

template<typename T , typename Tag = detail::TagDataTypeAny, typename U = struct DeferT>
template<auto U::* fieldSize, auto U::* fieldArray>
auto & opcua::DataTypeBuilder< T, Tag, U >::addField ( const char * fieldName)
inline

Add a structure array field (derive DataType from fieldArray).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 261 of file datatype.hpp.

◆ addUnionField() [1/2]

template<typename T , typename Tag , typename U >
template<auto U::* memberUnion, typename TField >
auto & opcua::DataTypeBuilder< T, Tag, U >::addUnionField ( const char * fieldName,
const UA_DataType & fieldType )

Add a union field.

Template Parameters
memberUnionMember pointer to the union, e.g. &S::Uni
TFieldType of the union field
Parameters
fieldNameHuman-readable field name
fieldTypeData type of the union field

Definition at line 418 of file datatype.hpp.

Referenced by opcua::DataTypeBuilder< T, Tag, U >::addUnionField().

◆ addUnionField() [2/2]

template<typename T , typename Tag = detail::TagDataTypeAny, typename U = struct DeferT>
template<auto U::* memberUnion, typename TField >
auto & opcua::DataTypeBuilder< T, Tag, U >::addUnionField ( const char * fieldName)
inline

Add a union field (derive DataType from TField).

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 280 of file datatype.hpp.

◆ build()

template<typename T , typename Tag , typename U >
DataType opcua::DataTypeBuilder< T, Tag, U >::build ( )
nodiscard

Create the actual DataType.

Definition at line 449 of file datatype.hpp.

Friends And Related Symbol Documentation

◆ DataTypeBuilder

template<typename T , typename Tag = detail::TagDataTypeAny, typename U = struct DeferT>
template<typename , typename , typename >
friend class DataTypeBuilder
friend

Definition at line 291 of file datatype.hpp.