open62541pp 0.18.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
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 308 of file datatype.hpp.

Public Member Functions

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

Static Public Member Functions

static auto createEnum (std::string_view typeName, NodeId typeId, NodeId binaryEncodingId)
 
static auto createStructure (std::string_view typeName, NodeId typeId, NodeId binaryEncodingId)
 
static auto createUnion (std::string_view 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 ( std::string_view  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 419 of file datatype.hpp.

◆ createStructure()

template<typename T , typename Tag , typename U >
auto opcua::DataTypeBuilder< T, Tag, U >::createStructure ( std::string_view  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 435 of file datatype.hpp.

◆ createUnion()

template<typename T , typename Tag , typename U >
auto opcua::DataTypeBuilder< T, Tag, U >::createUnion ( std::string_view  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 451 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 ( std::string_view  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 468 of file datatype.hpp.

◆ 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 ( std::string_view  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 350 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 ( std::string_view  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 495 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 ( std::string_view  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 371 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 ( std::string_view  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 528 of file datatype.hpp.

◆ 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 ( std::string_view  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 390 of file datatype.hpp.

◆ build()

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

Create the actual DataType.

Definition at line 555 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 401 of file datatype.hpp.