8 #include "Arp/System/Rsc/Services/Rsc.h" 9 #include "Arp/System/Rsc/Services/RscVariant.hxx" 10 #include "Arp/System/Rsc/Services/RscString.hxx" 11 #include "Arp/System/Rsc/Services/RscValue.hpp" 12 #include "Arp/System/Rsc/Services/RscException.hpp" 14 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
23 template<
int MaxStringSize>
77 RemotingReader* pReader =
nullptr;
78 ReadElementFunction readFieldFunction;
87 template<
int MaxStringSize>
89 : structInformation(structVariant.GetStructInformation())
91 if(structVariant.typeInfo.pReader ==
nullptr)
93 this->readFieldFunction = *structVariant.typeInfo.pReadElementFunction;
97 this->readFieldFunction = [&](
RscType expectedType,
byte * pValue)
99 return this->ReadRemotingValue(expectedType, pValue);
101 if(structVariant.typeInfo.pReader ==
nullptr)
105 this->pReader = structVariant.typeInfo.pReader;
109 template<
int MaxStringSize>
115 template<
int MaxStringSize>
120 if(value.ContainsTypeInformation())
122 value.InitComplexTypeInfo();
123 value.typeInfo.pReader = this->pReader;
124 if(this->pReader ==
nullptr)
126 value.typeInfo.pReadElementFunction = &this->readFieldFunction;
131 template<
int MaxStringSize>
135 RscType expectedType = GetRscTypeFrom(currentField);
136 if(!IsPrimitiveRscType(expectedType))
140 (void)this->readFieldFunction(expectedType, reinterpret_cast<byte*>(¤tField));
143 template<
int MaxStringSize>
149 template<
int MaxStringSize>
152 RscType valueType = this->pReader->ReadObjectType();
155 throw RscException((
int)RscErrors::InvalidData,
"{}: Expected data type '{}', but got '{}'", __FUNCTION__, expectedType, valueType);
160 arrayInformation = this->pReader->ReadArrayInformation();
166 nestedStructInformation.
FieldCount = this->pReader->ReadFieldCount();
169 RscValue::Read(*this->pReader, valueType, pValue, MaxStringSize);
const char * CStr(void) const
Returns pointer to internal buffer.
Definition: RscString.hxx:109
Helper class to read a struct from an RscVariant. This class uses the struct information stored in Rs...
Definition: RscStructReader.hxx:24
Complex datatype with implements IRscSerializable
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType. Only supported types of RemotingMarshalType are included.
Definition: RscType.hpp:27
Rsc container class for primitive data type, strings or information about arrays or structs...
Definition: RscVariant.hxx:39
void ReadNextField(T ¤tField)
Reads the next field of current struct. This method if field is primitve and known.
Definition: RscStructReader.hxx:133
Object type handled by Rsc as RscVariant
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:14
const byte * GetDataAddress(void) const
Gets a raw pointer to internal data buffer. To read data prefer CopyTo and to write prefer assignment...
Definition: RscVariant.hxx:495
RscStructReader & operator=(const RscStructReader &arg)=default
Assignment operator.
void SetType(RscType rscType)
Forces the internal RscType to be set to another RscType. This Method does no conversion or validatio...
Definition: RscVariant.hxx:507
This exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:14
size_t GetFieldCount(void) const
Gets the field count of the struct;
Definition: RscStructReader.hxx:110
Root namespace for the PLCnext API
System components used by the System, Device, Plc or Io domains.
~RscStructReader(void)=default
Destructs this instance and frees all resources.
Contains a static string with string lentgh up to N characters. The string has to be null terminated...
Definition: RscString.hxx:18
RscStructReader(const RscVariant< MaxStringSize > &structVariant)
Constructs an RscStructReader instance.
Definition: RscStructReader.hxx:88
unsigned char byte
The Arp character type.
Definition: PrimitiveTypes.hpp:23