8 #include "Arp/System/Rsc/Services/RscVariant.hxx" 9 #include "Arp/System/Rsc/Services/RscValue.hpp" 10 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
17 template<
int MaxStringSize>
58 void WriteRemotingValue(
RscType valueType,
const byte* pValue);
62 WriteElementFunction writeFieldFunction;
63 RemotingWriter* pWriter =
nullptr;;
71 template<
int MaxStringSize>
73 : structInformation(structVariant.GetStructInformation())
75 if(structVariant.typeInfo.pWriteElementFunction !=
nullptr)
77 this->writeFieldFunction = *structVariant.typeInfo.pWriteElementFunction;
81 this->writeFieldFunction = [&](
RscType valueType,
const byte * pValue)
83 this->WriteRemotingValue(valueType, pValue);
85 if(structVariant.typeInfo.pWriter ==
nullptr)
89 this->pWriter = structVariant.typeInfo.pWriter;
93 template<
int MaxStringSize>
99 this->writeFieldFunction(
RscType::Array, reinterpret_cast<const byte*>(&arrayInformation));
100 currentField.typeInfo.pWriter = this->pWriter;
101 if(this->pWriter ==
nullptr)
103 currentField.typeInfo.pWriteElementFunction = &this->writeFieldFunction;
109 this->writeFieldFunction(
RscType::Struct, reinterpret_cast<const byte*>(¤ttructInformation));
110 currentField.typeInfo.pWriter = this->pWriter;
111 if (this->pWriter ==
nullptr)
113 currentField.typeInfo.pWriteElementFunction = &this->writeFieldFunction;
122 template<
int MaxStringSize>
128 template<
int MaxStringSize>
132 RscType type = GetRscTypeFrom(currentField);
133 if(!IsPrimitiveRscType(type))
137 this->writeFieldFunction(type, reinterpret_cast<const byte*>(¤tField));
140 template<
int MaxStringSize>
145 this->pWriter->WriteArrayInformation(*reinterpret_cast<const RscArrayInformation*>(pValue));
148 this->pWriter->WriteObjectType(valueType);
149 RscValue::Write(*this->pWriter, valueType, pValue, MaxStringSize);
const char * CStr(void) const
Returns pointer to internal buffer.
Definition: RscString.hxx:109
~RscStructWriter(void)=default
Destructs this instance and frees all resources.
void WriteNextField(const T ¤tField)
Writes the next field with primitive Type.
Definition: RscStructWriter.hxx:130
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
RscStructWriter(const RscVariant< MaxStringSize > &structVariant)
Constructs an RscStructWriter instance.
Definition: RscStructWriter.hxx:72
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
This exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:14
RscStructWriter & operator=(const RscStructWriter &arg)=default
Assignment operator.
Root namespace for the PLCnext API
RscType GetType(void) const
Gets the RscType of the contained element
Definition: RscVariant.hxx:413
System components used by the System, Device, Plc or Io domains.
Helper class to write a struct from an RscVariant. This class uses the struct information stored in R...
Definition: RscStructWriter.hxx:18
Contains a static string with string lentgh up to N characters. The string has to be null terminated...
Definition: RscString.hxx:18
unsigned char byte
The Arp character type.
Definition: PrimitiveTypes.hpp:23