7 #include "Arp/System/Rsc/Services/Rsc.h" 8 #include "Arp/System/Commons/Logging.h" 9 #include "Arp/System/Commons/Exceptions/Exceptions.h" 10 #include "Arp/System/Rsc/Services/RscException.hpp" 11 #include "Arp/System/Rsc/Services/IRscReadEnumerator.hxx" 12 #include "Arp/System/Rsc/Services/RscReader.hpp" 13 #include "Arp/System/Rsc/Services/RscArrayReader.hpp" 16 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
43 RemotingReader& remotingReader;
44 size_t arrayLength = UndefinedArrayLength;
45 bool isArrayEnumerator;
48 size_t fieldCount = 0;
51 static constexpr
size_t UndefinedArrayLength = std::numeric_limits<size_t>::max();
58 : remotingReader(rscReader.GetRemotingReader())
59 , isArrayEnumerator(isArrayEnumeratorArg)
60 , rscType(GetRscTypeFrom(T()))
61 , fieldCount(StructInfo<T>().FieldCount)
70 Log::Error(
"Rsc Enumerating was not ended properly, call EndRead() method when reading was finished.");
77 if(this->isArrayEnumerator)
82 this->remotingReader.ReadBeginStruct(this->fieldCount);
86 this->remotingReader.ReadTag(this->rscType);
88 this->arrayLength = this->remotingReader.ReadArrayLength();
94 return this->arrayLength;
100 if(this->isArrayEnumerator)
102 if(this->arrayLength == 0)
115 RscType currentTypeCode = this->remotingReader.ReadEnumeratorTag(this->ended);
121 if(currentTypeCode != this->rscType)
123 throw RscException((
int)RscErrors::ProtocolViolation,
"Read false enumerator Tag: expected '{0}', received '{1}'", this->rscType, currentTypeCode);
127 size_t readFieldCount = this->remotingReader.ReadFieldCount();
128 if(readFieldCount != this->fieldCount)
130 throw RscException((
int)RscErrors::ProtocolViolation,
"Read false struct field count: expected '{0}', received '{1}'", this->fieldCount, readFieldCount);
134 RscValueAdapter<T> valueAdapter(current);
135 valueAdapter.Read(this->remotingReader,
false);
142 if (this->arrayLength == 0)
148 RscType elementType = this->remotingReader.ReadTag();
149 size_t arraySize = this->remotingReader.ReadArrayLength();
150 current =
RscArrayReader(arraySize, elementType, this->remotingReader);
157 if(this->isArrayEnumerator)
159 if(this->arrayLength != 0)
Reads data from Rsc
Definition: RscReader.hpp:23
size_t BeginRead(void) override
Begins the operation to read the enumerator.
Definition: RscReadEnumerator.hxx:75
Complex datatype with implements IRscSerializable
void EndRead(void) override
Ends the operation to read the enumerator. All enumerator elements had to be already been read...
Definition: RscReadEnumerator.hxx:155
~RscReadEnumerator(void)
Destructs this instance and frees all resources.
Definition: RscReadEnumerator.hxx:66
Helper class to read an array of primtive types from an RscVariant. This class uses the array informa...
Definition: RscArrayReader.hpp:22
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType. Only supported types of RemotingMarshalType are included.
Definition: RscType.hpp:27
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:14
bool ReadNext(T ¤t) override
Reads the next enumerator element.
Definition: RscReadEnumerator.hxx:98
Interface for reading an array or an enumerator. For regular enumerators UndefinedArrayLength is used...
Definition: IRscReadEnumerator.hxx:20
Enumerator type, handled by Rsc with IRscReadEnumerator and IRscWriteEnumerator
Root namespace for the PLCnext API
RscReadEnumerator(RscReader &rscReader, bool isArrayEnumerator)
Constructs an RscEnumeratorBase instance.
Definition: RscReadEnumerator.hxx:57
System components used by the System, Device, Plc or Io domains.
Implementation of IRscReadEnumerator used on client side.
Definition: RscReadEnumerator.hxx:23