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" 16 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
25 template<
int MaxStringSize>
79 RemotingReader* pReader =
nullptr;
80 ReadElementFunction readFieldFunction;
89 template<
int MaxStringSize>
91 : structInformation(structVariant.GetStructInformation())
93 if(structVariant.typeInfo.pReader ==
nullptr)
95 this->readFieldFunction = *structVariant.typeInfo.pReadElementFunction;
99 this->readFieldFunction = [&](
RscType expectedType,
byte * pValue)
101 return this->ReadRemotingValue(expectedType, pValue);
103 if(structVariant.typeInfo.pReader ==
nullptr)
107 this->pReader = structVariant.typeInfo.pReader;
111 template<
int MaxStringSize>
117 template<
int MaxStringSize>
122 if(value.ContainsTypeInformation())
124 value.InitComplexTypeInfo();
125 value.typeInfo.pReader = this->pReader;
126 if(this->pReader ==
nullptr)
128 value.typeInfo.pReadElementFunction = &this->readFieldFunction;
133 template<
int MaxStringSize>
137 RscType expectedType = GetRscTypeFrom(currentField);
138 if(!IsPrimitiveRscType(expectedType))
142 (void)this->readFieldFunction(expectedType, reinterpret_cast<byte*>(¤tField));
145 template<
int MaxStringSize>
151 template<
int MaxStringSize>
154 RscType valueType = this->pReader->ReadObjectType();
157 throw RscException((
int)RscErrors::InvalidData,
"{}: Expected data type '{}', but got '{}'", __FUNCTION__, expectedType, valueType);
162 arrayInformation = this->pReader->ReadArrayInformation();
168 nestedStructInformation.
FieldCount = this->pReader->ReadFieldCount();
171 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:26
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:37
void ReadNextField(T ¤tField)
Reads the next field of current struct. This method if field is primitve and known.
Definition: RscStructReader.hxx:135
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:490
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:502
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:112
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:90
unsigned char byte
The Arp character type.
Definition: PrimitiveTypes.hpp:23