PLCnext API Documentation 26.6.0.38
RscTypeDeduction.Impl.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Rsc/Commons/RscType.hpp"
9#include "Arp/Base/Rsc/Commons/RscSerializable.hpp"
10#include <type_traits>
11
12// forwards
13namespace Arp::Base::Commons::Security
14{
15class SecurityToken;
16}
17namespace Arp::Base::Rsc::Commons
18{
19class RscGuid;
20class RscVersion;
21template<int N> class RscString;
22template<int N> class RscSecureString;
23template<int N> class RscVariant;
24}
25
26namespace Arp::Base::Rsc::Commons::Impl
27{
28
30
31// concept BoundedCharArray
32template<class>
33struct IsBoundedCharArray : std::false_type {};
34
35template<size_t N>
36struct IsBoundedCharArray<char[N]> : std::true_type {};
37
38template<class T>
39concept BoundedCharArray = IsBoundedCharArray<T>::value;
40
41// concept RscArryType
42template <class T>
43concept ArrayType = std::is_array_v<T>&& !IsBoundedCharArray<T>::value;
44
45// GetRscType<T> implementation
46template<class T>
47constexpr RscType GetRscType(void)
48{
49 // REMARK: constexpr might only have a single return statement
50 return std::is_enum<T>::value ? GetRscType<typename underlying_enum_type<T>::type>() :
51 (
52 std::is_base_of<RscSerializable, T>::value ? RscType::Struct :
53 (
54 std::is_array<T>::value ? RscType::Array : RscType::None
55 )
56 );
57}
58
59template<>
60constexpr RscType GetRscType<boolean>()
61{
62 return RscType::Bool;
63}
64
65template<>
66constexpr RscType GetRscType<char8>()
67{
68 return RscType::Uint8;
69}
70
71template<>
72constexpr RscType GetRscType<char16>()
73{
74 return RscType::Char;
75}
76
77template<>
78constexpr RscType GetRscType<uint8>()
79{
80 return RscType::Uint8;
81}
82
83template<>
84constexpr RscType GetRscType<int8>()
85{
86 return RscType::Int8;
87}
88
89template<>
90constexpr RscType GetRscType<uint16>()
91{
92 return RscType::Uint16;
93}
94
95template<>
96constexpr RscType GetRscType<int16>()
97{
98 return RscType::Int16;
99}
100
101template<>
102constexpr RscType GetRscType<uint32>()
103{
104 return RscType::Uint32;
105}
106
107template<>
108constexpr RscType GetRscType<int32>()
109{
110 return RscType::Int32;
111}
112
113template<>
114constexpr RscType GetRscType<uint64>()
115{
116 return RscType::Uint64;
117}
118
119template<>
120constexpr RscType GetRscType<int64>()
121{
122 return RscType::Int64;
123}
124
125template<>
126constexpr RscType GetRscType<float32>()
127{
128 return RscType::Real32;
129}
130
131template<>
132constexpr RscType GetRscType<float64>()
133{
134 return RscType::Real64;
135}
136
137template<>
138constexpr RscType GetRscType<String>()
139{
140 return RscType::String;
141}
142
143template<>
144constexpr RscType GetRscType<char8*>()
145{
146 return RscType::String;
147}
148
149template<>
150constexpr RscType GetRscType<char8[]>()
151{
152 return RscType::String;
153}
154
155template<>
156constexpr RscType GetRscType<const char8*>()
157{
158 return RscType::String;
159}
160
161template<>
162constexpr RscType GetRscType<const char8[]>()
163{
164 return RscType::String;
165}
166
167template<>
168constexpr RscType GetRscType<SecurityToken>()
169{
170 return RscType::SecurityToken;
171}
172
173template<>
174constexpr RscType GetRscType<DateTime>()
175{
176 return RscType::DateTime;
177}
178
179template<>
180constexpr RscType GetRscType<RscVersion>()
181{
182 return RscType::Version;
183}
184
185template<>
186constexpr RscType GetRscType<RscGuid>()
187{
188 return RscType::Guid;
189}
190
191} // end of namespace Arp::Base::Rsc::Commons::Impl
192
This class is used for authorization of arbitrary operations.
Definition: SecurityToken.hpp:18
Definition: RscTypeDeduction.Impl.hpp:33