open62541pp
0.16.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
include
open62541pp
typeconverter.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <type_traits>
4
5
namespace
opcua
{
6
7
/**
8
* Type conversion from and to native types.
9
*
10
* Native types can be both `UA_*` types and wrapper classes (like `UA_Guid` and `Guid`).
11
* The `TypeConverter` is mainly used within the `Variant` class to set/get non-native types.
12
*
13
* Template specializations can be added for conversions of arbitrary types:
14
* @code
15
* namespace ::opcua {
16
* template <>
17
* struct TypeConverter<MyCustomType> {
18
* using NativeType = Guid;
19
*
20
* static void fromNative(const NativeType& src, MyCustomType& dst) {
21
* // ...
22
* }
23
*
24
* static void toNative(const MyCustomType& src, NativeType& dst) {
25
* // ...
26
* }
27
* };
28
* }
29
* @endcode
30
*/
31
template
<
typename
T,
typename
Enable =
void
>
32
struct
TypeConverter
;
33
34
/* -------------------------------------- Traits and helper ------------------------------------- */
35
36
namespace
detail {
37
38
template
<
typename
T,
typename
=
void
>
39
struct
IsConvertibleType
: std::false_type {};
40
41
template
<
typename
T>
42
struct
IsConvertibleType
<T, std::void_t<decltype(TypeConverter<T>{})>> : std::true_type {};
43
44
template
<
typename
T>
45
constexpr
bool
isConvertibleType
=
IsConvertibleType<T>::value
;
46
47
}
// namespace detail
48
49
}
// namespace opcua
opcua::detail::isConvertibleType
constexpr bool isConvertibleType
Definition
typeconverter.hpp:45
opcua
Definition
async.hpp:11
opcua::TypeConverter
Type conversion from and to native types.
Definition
typeconverter.hpp:32
opcua::detail::IsConvertibleType
Definition
typeconverter.hpp:39
Generated by
1.11.0