PLCnext API Documentation 24.0.0.71
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/Core/Arp.h"
12#include "Arp/System/Rsc/Services/RscVariant.hxx"
13
14namespace Arp { namespace System { namespace Nm { namespace Internal
15{
16
18template<typename T, int N>
19struct rscvariant_cast
20{
21 T operator()(const Rsc::Services::RscVariant<N>& value)
22 {
23 T result{};
24 value.CopyTo(result);
25 return result;
26 }
27};
28
29
31template<int N>
32struct rscvariant_cast<Rsc::Services::RscVariant<N>, N>
33{
34 Rsc::Services::RscVariant<N> operator()(const Rsc::Services::RscVariant<N>& value)
35 {
36 return value;
37 }
38};
39
40
42template<int N>
43struct rscvariant_cast<String, N>
44{
45 String operator()(const Rsc::Services::RscVariant<N>& value)
46 {
47 return value.GetChars();
48 }
49};
50
51
52} // namespace Internal
53
54
56template<typename T, int N>
58{
59 return Internal::rscvariant_cast<T, N>()(value);
60}
61
62
63}}} // end of namespace Arp::System::Nm
Rsc container class for primitive data type, strings or information about arrays or structs....
Definition: RscVariant.hxx:69
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:57
Root namespace for the PLCnext API