PLCnext API Documentation 25.0.2.69
RscSkipper.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Rsc/Commons/RscVariant.hxx"
9#include "Arp/Base/Rsc/Commons/RscArrayReader.hpp"
10#include "Arp/Base/Rsc/Commons/RscStructReader.hpp"
11namespace Arp::Base::Rsc::Commons::Services
12{
13
19{
20public: // construction
21 RscSkipper(void) = delete;
22
23public: // static operations
24 template<int N>
25 static void Skip(const RscVariant<N>& value);
26
27private: // static methods
28 template<int N>
29 static void SkipArray(RscType elementType, RscArrayReader& arrayReader);
30
31 template<int N>
32 static void SkipStruct(RscStructReader& structReader);
33};
34
36// inline methods of class RscSkipper
37
40template<int N>
41inline void RscSkipper::Skip(const RscVariant<N>& value)
42{
43 if (value.GetType() == RscType::Array)
44 {
45 RscArrayReader arrayReader(value);
46 SkipArray<N>(arrayReader.GetElementType(), arrayReader);
47 }
48 else if (value.GetType() == RscType::Struct)
49 {
50 RscStructReader structReader(value);
51 SkipStruct<N>(structReader);
52 }
53}
54
58template<int N>
59inline void RscSkipper::SkipArray(RscType elementType, RscArrayReader& arrayReader)
60{
61 for (size_t i = 0; i < arrayReader.GetSize(); i++)
62 {
63 if (arrayReader.GetDimensions() > 1)
64 {
65 RscArrayReader nextArrayReader = arrayReader.ReadNextArray();
66 SkipArray<N>(arrayReader.GetElementType(), nextArrayReader);
67 }
68 else if (elementType == RscType::Struct)
69 {
70 RscStructReader structReader = arrayReader.ReadNextStruct<N>();
71 SkipStruct<N>(structReader);
72 }
73 else
74 {
75 RscVariant<N> temp;
76 arrayReader.ReadNext(temp);
77 }
78 }
79}
80
83template<int N>
84inline void RscSkipper::SkipStruct(RscStructReader& structReader)
85{
86 for (size_t i = 0; i < structReader.GetFieldCount(); i++)
87 {
88 RscVariant<N> temp;
89 structReader.ReadNextField(temp);
90 Skip(temp);
91 }
92}
93
94} // end of namespace Arp::Base::Rsc::Commons::Services
Utility class to read an array of primitive types from RscVariant. This class uses the array informat...
Definition: RscArrayReader.hpp:22
void ReadNext(T &current)
Reads the next array value using the supplied callback function given by ArrayInformation of RscVaria...
Definition: RscArrayReader.hpp:86
size_t GetSize(void) const
Returns the number of values contained in the array.
Definition: RscArrayReader.cpp:96
RscType GetElementType(void) const
Returns the value type of the array elements.
Definition: RscArrayReader.cpp:103
RscArrayReader ReadNextArray(void)
Reads the next subarray of arrays with more than one dimension. The next subarray is read using a new...
Definition: RscArrayReader.cpp:134
size_t GetDimensions(void) const
Gets the count of the array dimensions.
Definition: RscArrayReader.cpp:110
RscStructReader ReadNextStruct(void)
Reads the next struct element.
Definition: RscArrayReader.hpp:145
Utility class to read dynamic structs.
Definition: RscStructReader.hpp:30
RscType GetType(void) const
Gets the RscType of the contained element
Definition: RscVariantBase.cpp:290
Rsc class for variant data types like primitive data type, strings or information about arrays or str...
Definition: RscVariant.hxx:57
Pure static class to skip remaining data from remoting stream.
Definition: RscSkipper.hpp:19
RscSkipper(void)=delete
Makes this class pure static.
static void Skip(const RscVariant< N > &value)
Skips the remaining data of the variant value from remoting stream, if it's an array or struct.
Definition: RscSkipper.hpp:41