8#include "Arp/Base/Rsc/Commons/Rsc.hpp"
9#include "Arp/Base/Rsc/Commons/RscType.hpp"
10#include "Arp/Base/Rsc/Commons/RscTypeDeduction.hpp"
11#include "Arp/Base/Rsc/Commons/RscArrayInfo.hpp"
12#include "Arp/Base/Rsc/Commons/RscStructInfo.hpp"
13#include "Arp/Base/Commons/Exceptions/InvalidCastException.hpp"
14#include "Arp/Base/Commons/Exceptions/NotSupportedException.hpp"
17namespace Arp::Base::Rsc::Commons::Internal
19class RscVariantAccessor;
22namespace Arp::Base::Rsc::Commons
41 friend class Arp::Base::Rsc::Commons::Internal::RscVariantAccessor;
74 void SetType(RscType value);
75 RscType GetType(
void)
const;
76 RscType GetValueType(
void)
const;
77 bool IsComplexType(
void)
const;
78 bool IsArray(
void)
const;
79 bool IsStruct(
void)
const;
80 bool IsFormattable(
void)
const;
81 size_t GetDataSize(
void)
const;
82 size_t GetMaxStringSize(
void)
const;
83 size_t GetBufferSize(
void)
const;
84 RscType GetArrayElementType(
void)
const;
85 size_t GetArraySize(
void)
const;
86 size_t GetArrayDimensions(
void)
const;
87 size_t GetArrayFieldCount(
void)
const;
88 size_t GetFieldCount(
void)
const;
89 byte* GetDataAddress(
void);
90 const byte* GetDataAddress(
void)
const;
91 const char* GetChars(
void)
const;
94 void Assign(
const char* input, RscType rscType = RscType::String);
95 void Assign(
const char* input,
size_t length, RscType rscType = RscType::String);
96 void Assign(
const char16* input,
size_t length);
97 void Assign(
const String& value);
98 void CopyTo(
String& value)
const;
99 String ToString(
void)
const;
100 void Clear(
bool clearBuffer =
false);
108 bool HasArrayInfo(
void)
const;
110 void SetArrayInfo(
size_t size, RscType elementType = RscType::None,
size_t dimensions = 1,
size_t fieldCount = 0);
113 bool HasStructInfo(
void)
const;
114 void SetStructInfo(
size_t fieldCount);
117 bool HasReadElementFunction(
void)
const;
120 bool HasWriteElementFunction(
void)
const;
123 void ResetComplexTypeInfo(
void);
126 template<
int N>
void Assign(
char value[N]);
127 template<
int N>
void Assign(
const char value[N]);
130 template<
class T>
void Assign(
const T& value);
131 template<
class T>
void CopyTo(T& value)
const;
132 template<
class T> T GetValue(
void)
const;
133 template<
class T> T* GetValueAddress(
void);
134 template<
class T>
const T* GetValueAddress(
void)
const;
137 void SetBufferInfo(
byte* pDataBuffer,
size_t dataBufferSize,
bool isDynamicString);
138 bool HasReader(
void)
const;
139 bool HasWriter(
void)
const;
146 bool ProvidesDynamicString(
void)
const;
147 String& GetDynamicString(
void);
148 const String& GetDynamicString(
void)
const;
151 static size_t DetermineBufferSize(RscType type);
154 struct ComplexTypeInfo
161 ComplexVariantInfo complexVariantInfo{};
164 ReadElementFunction* pReadElementFunction =
nullptr;
165 mutable WriteElementFunction* pWriteElementFunction =
nullptr;
169 RscType type = RscType::None;
170 byte* pBuffer =
nullptr;
171 size_t bufferSize = 0;
172 bool providesDynamicString =
false;
219 if (rscType == RscType::None)
224 *this->GetValueAddress<T>() = value;
245 return reinterpret_cast<T*
>(this->
pBuffer);
254 return reinterpret_cast<const T*
>(this->
pBuffer);
266 throw InvalidCastException(
"Cannot copy value to argument: RscVariant contains data type {0} but arg is of type {1}", this->
GetType(), argType);
268 value = *this->GetValueAddress<T>();
This exception is thrown when an invalid cast occurs.
Definition: InvalidCastException.hpp:17
This exception is thrown when a not supported operation is invoked.
Definition: NotSupportedException.hpp:16
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
This (meta programming) class provides the C++ type-name of the as template argument passed type.
Definition: TypeName.hxx:20
Contains information to marshal dynamic arrays.
Definition: RscArrayInfo.hpp:14
Specialized implementation of RscString for secure context.
Definition: RscSecureString.hxx:16
This class is a base class of template class RscString.
Definition: RscStringBase.hpp:27
size_t GetLength(void) const
Gets the length of this string.
Definition: RscStringBase.cpp:49
const char * CStr(void) const
Returns a const char pointer to the internal string buffer.
Definition: RscStringBase.cpp:63
Contains a static string with string lentgh up to N characters. The string shall be null terminated.
Definition: RscString.hxx:24
Contains information to marshal structs.
Definition: RscStructInfo.hpp:17
static constexpr RscType GetFrom(const T &)
Gets the RscType of the as argument passed parameter.
Definition: RscTypeDeduction.hpp:77
This class is a base class of template class RscVariant.
Definition: RscVariantBase.hpp:40
void SetType(RscType value)
Forces the internal RscType to be set to another RscType.
Definition: RscVariantBase.cpp:139
RscVariantBase & operator=(RscVariantBase &&arg) noexcept
The move-assign operator.
~RscVariantBase(void)
The default destructor.
RscType GetType(void) const
Gets the RscType of the contained element
Definition: RscVariantBase.cpp:290
std::function< void(RscType fieldType, const RscVariantBase &value)> WriteFieldFunction
The write field delegate type.
Definition: RscVariantBase.hpp:45
RscVariantBase(RscVariantBase &&arg) noexcept
The move constructor.
std::function< void(RscType elementType, const RscVariantBase &value)> WriteElementFunction
The write element delegate type.
Definition: RscVariantBase.hpp:47
ComplexTypeInfo typeInfo
The type info of this variant.
Definition: RscVariantBase.hpp:174
T GetValue(void) const
Converts this value to the given type T .
Definition: RscVariantBase.hpp:232
RscVariantBase(const RscVariantBase &arg)
The copy constructor.
RscType GetValueType(void) const
Gets the raw value type as RscType of the contained element.
Definition: RscVariantBase.cpp:301
String dynamicString
The dynamic string storage.
Definition: RscVariantBase.hpp:173
std::function< void(RscType elementType, RscVariantBase &value)> ReadElementFunction
The read element delegate type.
Definition: RscVariantBase.hpp:46
byte * pBuffer
The buffer of this variant (usually applied by RscVariant<T>)
Definition: RscVariantBase.hpp:170
RscVariantBase & operator=(const RscVariantBase &arg)
The assign operator.
std::function< void(RscType fieldType, RscVariantBase &value)> ReadFieldFunction
The read field delegate type.
Definition: RscVariantBase.hpp:44
void Assign(const char *input, RscType rscType=RscType::String)
Assigns an UTF8 string to this instance.
Definition: RscVariantBase.cpp:776
void CopyTo(String &value) const
Copies the content of this variant to a string.
Definition: RscVariantBase.cpp:858
T * GetValueAddress(void)
Gets the address of the contained value as type T *.
Definition: RscVariantBase.hpp:243
Reads marshaled data of RSC services.
Definition: RscReader.hpp:34
Writes marshalled data of RSC services.
Definition: RscWriter.hpp:34
char16_t char16
The Arp character type of 2 byte size.
Definition: PrimitiveTypes.hpp:49
char8_t char8u
The Arp UTF8 character type of 1 byte size.
Definition: PrimitiveTypes.hpp:47
@ Equals
Start recording if TriggerVariable1 is equal to TriggerVariable2.
@ Write
Specifies write access to the file. Data can be written to the file and the file pointer can be moved...
@ Read
Specifies read access to the file. Data can be read from the file and the file pointer can be moved....
Definition: RscVariantBase.hpp:157