ReflectedVariant.h
// ReflectedVariant.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2022
@import "IObject.h"
@import "ReflectedType.h"
@import "ReflectedField.h"
namespace ceda
{
$struct+ ReflectedVariant <<os>>
{
bool operator<(const ReflectedVariant& rhs) const { return this < &rhs; }
bool operator==(const ReflectedVariant& rhs) const { return this == &rhs; }
$ConstStringZ GetName() const { return name; }
$ssize_t GetSize() const { return ops.size; }
$ssize_t GetNumFields() const { return numFields; }
$const ReflectedField& GetField(ssize_t i) const { return fields[i]; }
$uint32 GetTypeOperationFlags() const { return ops.GetTypeOperationFlags(); }
void Write(xostream& os) const;
//////////////// State //////////////////
@if (!CEDA_ENABLE_STRING_TABLES)
{
const octet_t* byteCode;
}
ConstStringZ name;
const octet_t* metaData;
const ReflectedField* fields;
ssize_t numFields;
ConstStringZ const* stringTable;
const TypeOps& ops;
};
template<typename T>
struct GetReflectedType_class<T, std::enable_if_t<!std::is_const<T>::value && !std::is_volatile<T>::value && IsReflectedVariant<T>::value>>
{
static inline ReflectedType get()
{
ReflectedType r;
r.tag = EReflectedTypeTag::Variant;
r.Variant = &GetReflectedVariant<T>();
return r;
}
};
} // namespace ceda