PLCnext API Documentation 23.0.2.9
RscVariantHelpers.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
9// TODO Move to Apr::System::Rsc::Services ?
10
11#include "Arp/System/Rsc/Services/RscVariant.hxx"
12
13namespace Arp { namespace System { namespace Nm { namespace Internal
14{
15
17template<typename T, int N>
18struct rscvariant_cast
19{
20 T operator()(const Rsc::Services::RscVariant<N>& value)
21 {
22 T result{};
23 value.CopyTo(result);
24 return result;
25 }
26};
27
28
30template<int N>
31struct rscvariant_cast<Rsc::Services::RscVariant<N>, N>
32{
33 Rsc::Services::RscVariant<N> operator()(const Rsc::Services::RscVariant<N>& value)
34 {
35 return value;
36 }
37};
38
39
41template<int N>
42struct rscvariant_cast<String, N>
43{
44 String operator()(const Rsc::Services::RscVariant<N>& value)
45 {
46 return value.GetChars();
47 }
48};
49
50
51} // namespace Internal
52
53
55template<typename T, int N>
57{
58 return Internal::rscvariant_cast<T, N>()(value);
59}
60
61
62}}} // end of namespace Arp::System::Nm
Rsc container class for primitive data type, strings or information about arrays or structs....
Definition: RscVariant.hxx:68
Arp::BasicString< char8 > String
The Arp String class.
Definition: TypeSystem.h:27
@ System
System components used by the System, Device, Plc or Io domains.
T rscvariant_cast(const Rsc::Services::RscVariant< N > &value)
Casts an RscVariant to T
Definition: RscVariantHelpers.hpp:56
Root namespace for the PLCnext API