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>
21 using WriteElementFunction = RscVariant<>::WriteElementFunction;
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);
This exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:15
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:15
Contains a static string with string lentgh up to N characters. The string has to be null terminated.
Definition: RscString.hxx:21
const char * CStr(void) const
Returns pointer to internal buffer.
Definition: RscString.hxx:111
Helper class to write a struct from an RscVariant. This class uses the struct information stored in R...
Definition: RscStructWriter.hxx:19
RscStructWriter(const RscStructWriter &arg)=default
Copy constructor.
void WriteNextField(const T ¤tField)
Writes the next field with primitive Type.
Definition: RscStructWriter.hxx:130
~RscStructWriter(void)=default
Destructs this instance and frees all resources.
RscStructWriter & operator=(const RscStructWriter &arg)=default
Assignment operator.
RscStructWriter(const RscVariant< MaxStringSize > &structVariant)
Constructs an RscStructWriter instance.
Definition: RscStructWriter.hxx:72
Rsc container class for primitive data type, strings or information about arrays or structs....
Definition: RscVariant.hxx:39
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:514
RscType GetType(void) const
Gets the RscType of the contained element
Definition: RscVariant.hxx:432
@ System
System components used by the System, Device, Plc or Io domains.
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType....
Definition: RscType.hpp:37
@ Struct
Complex datatype with implements IRscSerializable
Root namespace for the PLCnext API