7 #include "Arp/System/Rsc/Services/Rsc.h" 8 #include "Arp/System/Rsc/Services/RscValueAdapter.hxx" 9 #include "Arp/System/Rsc/Services/RscStream.hpp" 10 #include "Arp/System/Rsc/Services/RemotingWriter.hpp" 12 #include <type_traits> 20 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
24 class RscClientContext;
25 class RscStreamAdapter;
34 RscWriter(BinaryWriter2& remotingWriter, RscClientContext* pClientContext =
nullptr);
53 RemotingWriter& GetRemotingWriter(
void);
60 void WriteConfirmation(
bool flush =
false);
74 template<
class T>
void Write(
const T& value);
82 template<
class T>
void Write(
const T& value,
bool writeTag);
89 template<
int N>
void WriteString(
const String& value);
96 template<
int N>
void WriteString(
const char(&value)[N]);
103 template<
class T>
void WriteObject(
const T& value);
110 template<
int N>
void WriteObjectString(
const String& value);
117 template<
int N>
void WriteObjectString(
const char(&value)[N]);
124 template<
class T>
void WriteArray(
const std::vector<T>& values);
131 template<
class T>
void WriteArray(
const std::vector<std::vector<T>>& values);
139 template<
class T,
size_t N>
void WriteArray(
const std::array<T, N>& values);
147 template<
class T>
void BeginArray(
size_t size);
150 RemotingWriter remotingWriter;
156 inline RscWriter::RscWriter(BinaryWriter2& remotingWriter, RscClientContext* pClientContextArg)
157 : remotingWriter(remotingWriter, *this, pClientContextArg)
163 return this->remotingWriter;
168 this->remotingWriter.WriteConfirmation(flush);
179 RscValueAdapter<T> valueAdapter(value);
180 valueAdapter.Write(this->remotingWriter);
186 RscValueAdapter<T> valueAdapter(value);
187 valueAdapter.Write(this->remotingWriter, writetTag);
193 this->remotingWriter.WriteStringInternal(value, N);
199 this->remotingWriter.WriteStringInternal(value, N);
205 size_t length = values.size();
206 this->BeginArray<T>(length);
207 for (
size_t i = 0; i < length; ++i)
209 const T& value = values[i];
210 RscValueAdapter<T> valueAdapter(value);
211 valueAdapter.Write(this->remotingWriter,
false);
219 this->BeginArray<T>(values.size());
220 for(
const std::vector<T>& innerArray : values)
222 this->remotingWriter.WriteArrayLength(innerArray.size());
224 for(
const T& value : innerArray)
226 RscValueAdapter<T> valueAdapter(value);
227 valueAdapter.Write(this->remotingWriter,
false);
232 template<
class T,
size_t N>
235 this->BeginArray<T>(N);
236 for(
size_t i = 0; i < N; ++i)
238 const T& value = values[i];
239 RscValueAdapter<T> valueAdapter(value);
240 valueAdapter.Write(this->remotingWriter,
false);
245 inline void RscWriter::BeginArray(
size_t size)
247 RscType elementType = GetRscTypeFrom(T());
251 this->remotingWriter.WriteBeginStruct(StructInfo<T>().FieldCount);
255 this->remotingWriter.WriteTag(elementType);
257 this->remotingWriter.WriteArrayLength(size);
264 this->remotingWriter.WriteObjectType(GetRscTypeFrom(value));
271 this->remotingWriter.WriteObjectString(RscStringEncoding::Utf8, value);
277 this->remotingWriter.WriteObjectString(RscStringEncoding::Utf8, value);
void WriteString(const String &value)
Writes a string in format Utf-8.
Definition: RscWriter.hpp:191
void Write(const T &value)
Writes an element of T from Rsc. Datatag and format is determined deducted by type of T...
Definition: RscWriter.hpp:177
Complex datatype with implements IRscSerializable
Writes data to Rsc.
Definition: RscWriter.hpp:30
RemotingWriter & GetRemotingWriter(void)
Returns reference to RemotingWriter
Definition: RscWriter.hpp:161
void WriteConfirmation(bool flush=false)
Sends a confirmation message to remote station.
Definition: RscWriter.hpp:166
void WriteArray(const std::vector< T > &values)
Writes an array to Rsc. The data to write has to be stored in a std::vector.
Definition: RscWriter.hpp:203
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType. Only supported types of RemotingMarshalType are included.
Definition: RscType.hpp:35
Definition: RemotingReader.hpp:10
This class serves as adapter between Rsc streams and streams from Arp::System::Commons::Io, e.g. file streams.
Definition: RscStreamAdapter.hpp:19
Enables Rsc services to marshal large data packets as stream.
Definition: RscStream.hpp:19
Root namespace for the PLCnext API
void WriteObject(const T &value)
Writes an object. Datatag and format is determined deducted by type of T. This method doesn't support...
Definition: RscWriter.hpp:262
RscStream GetStream()
Creates an instance of RscStream initialized to write stream data.
Definition: RscWriter.hpp:171
System components used by the System, Device, Plc or Io domains.
void WriteObjectString(const String &value)
Writes a string in object format as Utf8 string.
Definition: RscWriter.hpp:269