PLCnext API Documentation 25.0.2.69
RscTypeDeduction.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Rsc/Commons/RscTypeDeduction.Impl.hpp"
9
10namespace Arp::Base::Rsc::Commons
11{
12
14template<class T>
15concept ArrayType = Arp::Base::Rsc::Commons::Impl::ArrayType<T>;
16
18template<class T>
19concept BoundedCharArray = Arp::Base::Rsc::Commons::Impl::BoundedCharArray<T>;
20
24{
25public: // Get operations
26 template<class T> constexpr RscType Get(void);
27 template<ArrayType T> constexpr RscType Get(void);
28 template<BoundedCharArray T> constexpr RscType Get(void);
29
30public: // GetFrom(const T&) operations
31 template<class T> constexpr static RscType GetFrom(const T&);
32 template<int N> constexpr static RscType GetFrom(char[N]);
33 template<int N> constexpr static RscType GetFrom(const char[N]);
34 template<int N> constexpr static RscType GetFrom(const RscString<N>&);
35 template<int N> constexpr static RscType GetFrom(const RscVariant<N>&);
36 template<int N> constexpr static RscType GetFrom(const RscSecureString<N>&);
37
38 constexpr static RscType GetFrom(char*);
39 constexpr static RscType GetFrom(const char*);
40};
41
46template<class T>
47constexpr RscType RscTypeDeduction::Get()
48{
49 return GetFrom(T()); // this is only supported (compiles) if T is default constructible
50}
51
56template<ArrayType T>
57constexpr RscType RscTypeDeduction::Get()
58{
59 return RscType::Array;
60}
61
66template<BoundedCharArray T>
67constexpr RscType RscTypeDeduction::Get()
68{
69 return RscType::String;
70}
71
76template<class T>
77constexpr RscType RscTypeDeduction::GetFrom(const T&)
78{
79 return Arp::Base::Rsc::Commons::Impl::GetRscType<T>();
80}
81
89constexpr RscType RscTypeDeduction::GetFrom(char*)
90{
91 return RscType::String;
92}
93
101constexpr RscType RscTypeDeduction::GetFrom(const char*)
102{
103 return RscType::String;
104}
105
113template<int N>
114constexpr RscType RscTypeDeduction::GetFrom(char[N])
115{
116 return RscType::String;
117}
118
126template<int N>
127constexpr RscType RscTypeDeduction::GetFrom(const char[N])
128{
129 return RscType::String;
130}
131
139template<int N>
141{
142 return RscType::String;
143}
144
152template<int N>
154{
155 return RscType::Object;
156}
157
165template<int N>
167{
168 return RscType::SecureString;
169}
170
171} // end of namespace Arp::Base::Rsc::Commons
172
Specialized implementation of RscString for secure context.
Definition: RscSecureString.hxx:16
Contains a static string with string lentgh up to N characters. The string shall be null terminated.
Definition: RscString.hxx:24
This class is used to deduct RSC types automatically by compilation.
Definition: RscTypeDeduction.hpp:24
constexpr RscType Get(void)
Gets the RscType of the as argument passed template parameter.
Definition: RscTypeDeduction.hpp:47
static constexpr RscType GetFrom(const T &)
Gets the RscType of the as argument passed parameter.
Definition: RscTypeDeduction.hpp:77
Rsc class for variant data types like primitive data type, strings or information about arrays or str...
Definition: RscVariant.hxx:57
Defines a concept for RSC arrays.
Definition: RscTypeDeduction.hpp:15
Defines a concept for RSC char arrays.
Definition: RscTypeDeduction.hpp:19