Add Variant::AsStructure to comparision operator between VariantType and ScriptingTypeHandle
This commit is contained in:
@@ -255,6 +255,13 @@ bool VariantType::operator==(const VariantType& other) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VariantType::operator==(const ScriptingTypeHandle& type) const
|
||||
{
|
||||
if (Type == Null)
|
||||
return !type;
|
||||
return type && type.GetType().Fullname == GetTypeName();
|
||||
}
|
||||
|
||||
void VariantType::SetTypeName(const StringView& typeName)
|
||||
{
|
||||
if (StringUtils::Length(TypeName) != typeName.Length())
|
||||
|
||||
@@ -10,6 +10,7 @@ struct Transform;
|
||||
struct CommonValue;
|
||||
template<typename T>
|
||||
class AssetReference;
|
||||
struct ScriptingTypeHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an object type that can be interpreted as more than one type.
|
||||
@@ -120,6 +121,7 @@ public:
|
||||
VariantType& operator=(const VariantType& other);
|
||||
bool operator==(const Types& type) const;
|
||||
bool operator==(const VariantType& other) const;
|
||||
bool operator==(const ScriptingTypeHandle& type) const;
|
||||
|
||||
FORCE_INLINE bool operator!=(const VariantType& other) const
|
||||
{
|
||||
@@ -345,6 +347,14 @@ public:
|
||||
Array<Variant, HeapAllocation>& AsArray();
|
||||
const Array<Variant, HeapAllocation>& AsArray() const;
|
||||
|
||||
template<typename T>
|
||||
const T* AsStructure() const
|
||||
{
|
||||
if (Type.Type == VariantType::Structure && Type == T::TypeInitializer)
|
||||
return (const T*)AsBlob.Data;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
void SetType(const VariantType& type);
|
||||
void SetType(VariantType&& type);
|
||||
|
||||
Reference in New Issue
Block a user