3#include <Foundation/Types/Variant.h>
36 using Type =
const char*;
37 using RttiType =
const char*;
56 value = !std::is_const<typename plTypeTraits<T>::NonReferencePointerType>::value,
65 value = !std::is_const<typename plTypeTraits<T>::NonReferencePointerType>::value,
72template <class T, class C = typename plCleanType<T>::Type>
93template <class T, class C = typename plCleanType<T>::Type>
115 class C =
typename plCleanType<T>::Type,
125 void operator=(RealType* rhs) { m_value = rhs; }
126 void operator=(RealType&& rhs)
129 *m_value.
Get<RealType*>() = rhs;
134template <
class T,
class S>
143 void operator=(
plEnum<S>&& rhs) { m_value =
static_cast<plInt64
>(rhs.GetValue()); }
148template <
class T,
class S>
157 void operator=(
plBitflags<S>&& rhs) { m_value =
static_cast<plInt64
>(rhs.GetValue()); }
162template <
class T,
class C>
171 void operator=(T&& rhs) { m_value = rhs; }
184 void operator=(T&& rhs) { m_value = rhs; }
197 void operator=(T&& rhs) { m_value = rhs; }
207 class C =
typename plCleanType<T>::Type,
219 operator RealType&() {
return *m_value.
Get<RealType*>(); }
221 operator RealType*() {
return m_value.
IsValid() ? m_value.
Get<RealType*>() :
nullptr; }
226template <
class T,
class S>
234 m_realValue =
static_cast<typename S::Enum
>(m_value.
ConvertTo<plInt64>());
237 operator const plEnum<S>&() {
return m_realValue; }
238 operator const plEnum<S>*() {
return m_value.
IsValid() ? &m_realValue :
nullptr; }
244template <
class T,
class S>
252 m_realValue =
static_cast<typename S::Enum
>(m_value.
ConvertTo<plInt64>());
257 m_value =
static_cast<plInt64
>(m_realValue.GetValue());
260 operator plEnum<S>&() {
return m_realValue; }
261 operator plEnum<S>*() {
return m_value.
IsValid() ? &m_realValue :
nullptr; }
267template <
class T,
class S>
275 m_realValue.SetValue(
static_cast<typename S::StorageType
>(m_value.
ConvertTo<plInt64>()));
285template <
class T,
class S>
293 m_realValue.SetValue(
static_cast<typename S::StorageType
>(m_value.
ConvertTo<plInt64>()));
298 m_value =
static_cast<plInt64
>(m_realValue.GetValue());
308template <
class T,
class C>
322 return *m_value.
Get<RealType*>();
324 return m_value.
Get<RealType>();
332 return m_value.
IsValid() ? m_value.
Get<RealType*>() :
nullptr;
334 return m_value.
IsValid() ? &m_value.
Get<RealType>() :
nullptr;
340template <
class T,
class C>
354 return *m_value.
Get<RealType*>();
356 return const_cast<RealType&
>(m_value.
Get<RealType>());
361 return m_value.
IsValid() ? m_value.
Get<RealType*>() :
nullptr;
363 return m_value.
IsValid() ? &
const_cast<RealType&
>(m_value.
Get<RealType>()) :
nullptr;
377 operator const plVariant&() {
return m_value; }
378 operator const plVariant*() {
return &m_value; }
391 operator plVariant&() {
return m_value; }
392 operator plVariant*() {
return &m_value; }
461 operator const char*() {
return m_value.IsValid() ? m_value.Get<
plString>().GetData() :
nullptr; }
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
bool IsValid() const
Returns whether this variant stores any other type than 'Invalid'.
Definition Variant_inl.h:274
T ConvertTo(plResult *out_pConversionStatus=nullptr) const
Tries to convert the stored value to the given type. The optional status parameter can be used to che...
Definition Variant_inl.h:421
plTypedPointer GetWriteAccess()
Returns an writable plTypedPointer to the internal data. If the data is currently shared a clone will...
Definition Variant.cpp:391
Type::Enum GetType() const
Returns the exact plVariant::Type value.
Definition Variant_inl.h:351
const T & Get() const
Returns the variants value as the provided type.
bool IsA() const
Returns whether the stored type is exactly the given type.
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Definition VariantAdapter.h:7
Definition VariantAdapter.h:28
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition VariantAdapter.h:44
Used to determine if the given type is a build-in standard variant type.
Definition VariantAdapter.h:74
Used to determine if the given type can be stored by value inside an plVariant (either standard type ...
Definition VariantAdapter.h:95
typename std::remove_const< typename std::remove_reference< typename std::remove_pointer< T >::type >::type >::type NonConstReferencePointerType
removes reference, const and pointer qualifier Note that this removes the const and reference of the ...
Definition TypeTraits.h:225
Used to implicitly retrieve any value from an plVariant to be used as a function argument using the a...
Definition VariantAdapter.h:211
Used to automatically assign any value to an plVariant using the assignment rules outlined in plAbstr...
Definition VariantAdapter.h:118
@ CustomTypeCast
Custom object types.
Definition VariantType.h:90
A helper struct to convert the C++ type, which is passed as the template argument,...
Definition VariantType.h:97
@ TypedPointer
The variant stores an plTypedPointer value. Reflected type and data queries will match the pointed to...
Definition VariantType.h:71
@ FirstStandardType
*** Types that are flagged as 'StandardTypes' (see DetermineTypeFlags) ***
Definition VariantType.h:30