8#include "Arp/Base/Rsc/Commons/Rsc.hpp"
9#include "Arp/Base/Rsc/Commons/RscArrayWriter.hpp"
10#include "Arp/Base/Rsc/Commons/IRscWriteEnumerator.hxx"
11#include "Arp/Base/Rsc/Commons/Services/RscWriter.hpp"
12#include "Arp/Base/Commons/Exceptions/InvalidOperationException.hpp"
14namespace Arp::Base::Rsc::Commons::Services
32 void BeginWrite(
size_t currentArrayLength = (
size_t) -1)
override;
39 bool isArrayEnumerator =
false;
40 size_t arrayLength = 0;
43 size_t fieldCount = 0;
74 : isArrayEnumerator(isArrayEnumerator)
75 , rscWriter(rscWriter)
87 this->arrayLength = currentArrayLength;
89 if(this->isArrayEnumerator)
91 if(this->arrayLength == (
size_t) -1)
95 this->rscWriter.
WriteTag(RscType::Array);
97 if(this->rscType == RscType::Struct)
103 this->rscWriter.
WriteTag(this->rscType);
109 if(this->arrayLength != (
size_t) -1)
111 throw ArgumentException(
"Array length could not be defined for standard enumerators.");
113 this->rscWriter.
WriteTag(RscType::Enumerator);
123 if(this->isArrayEnumerator)
125 if(this->arrayLength == 0)
131 this->rscWriter.
Write(current, this->isConcreteType);
136 if(this->rscType == RscType::Struct)
140 this->rscWriter.
Write(current,
true);
152 this->rscWriter.
WriteTag(RscType::Array);
153 this->rscWriter.
WriteTag(arrayElementType);
155 return RscArrayWriter(arraySize, arrayElementType, this->rscWriter);
166 if(this->isArrayEnumerator)
168 if(this->arrayLength != 0)
This exception is thrown when an invalid argument occurs.
Definition: ArgumentException.hpp:17
This exception is thrown when an operation cannot be executed because the related state is invalid.
Definition: InvalidOperationException.hpp:16
Interface for writing an array enumeration or enumeration of unspefied length.
Definition: IRscWriteEnumerator.hxx:20
Helper class to write a dynamic array of primtive types from RscVariant. This class uses the array in...
Definition: RscArrayWriter.hpp:23
This class is used to deduct RSC types automatically by compilation.
Definition: RscTypeDeduction.hpp:24
constexpr RscType Get(void)
Gets the RscType of the as argument passed template parameter.
Definition: RscTypeDeduction.hpp:47
static bool IsConcreteType(RscType type)
Determines if the supplied type specifies a concrete type, i.e not unspecified and not object.
Definition: RscTypeInfo.cpp:242
Implementation of IRscWriteEnumerator used on client side.
Definition: RscWriteEnumerator.hxx:20
void WriteNext(const T ¤t) override
Writes the next value of the enumeration.
Definition: RscWriteEnumerator.hxx:121
void BeginWrite(size_t currentArrayLength=(size_t) -1) override
This operation is called at the begin of writing the enumeration.
Definition: RscWriteEnumerator.hxx:85
RscWriteEnumerator(RscWriter &rscWriter, bool isArrayEnumerator)
Constructs an RscEnumeratorBase instance.
Definition: RscWriteEnumerator.hxx:73
void EndWrite(void) override
This operation has to be called when the enumerating has finished.
Definition: RscWriteEnumerator.hxx:164
RscWriteEnumerator(RscWriteEnumerator &&arg) noexcept
The default move constructor.
~RscWriteEnumerator(void) noexcept
Destructs this instance and checks if the enumerations has ended.
RscWriteEnumerator & operator=(RscWriteEnumerator &&arg) noexcept
The default move-assignment operator.
Writes marshalled data of RSC services.
Definition: RscWriter.hpp:34
void WriteFieldCount(size_t fieldCount)
Writes the field count of a struct to RSC.
Definition: RscWriter.cpp:132
void WriteTag(RscType tag)
Writes a data tag to RSC.
Definition: RscWriter.cpp:125
void WriteArrayLength(size_t arraySize)
Writes the length of an array to RSC.
Definition: RscWriter.cpp:139
void WriteEnumeratorTag(RscType tag)
Writes an enumerator tag to RSC.
Definition: RscWriter.cpp:153
void Write(const RscPtr &value, bool omitTag=false)
Writes a value to RSC.
Definition: RscWriter.cpp:78
void WriteStructInfo(size_t fieldCount)
Writes the struct info to RSC.
Definition: RscWriter.cpp:146
This class provides the number of fields of a concrete struct. This class is specialized for concrete...
Definition: StructInfo.hxx:26