Add ctor for Variant from Span<byte>

This commit is contained in:
2022-01-26 16:55:38 +01:00
parent 18b156ad44
commit d86e4090b8
3 changed files with 18 additions and 0 deletions
+2
View File
@@ -86,6 +86,8 @@ struct BoundingFrustum;
struct Color;
struct Color32;
struct Variant;
template<typename T>
class Span;
class HeapAllocation;
template<int Capacity>
class FixedAllocation;
+15
View File
@@ -773,6 +773,21 @@ Variant::Variant(const Dictionary<Variant, Variant>& v)
AsDictionary = New<Dictionary<Variant, Variant>>(v);
}
Variant::Variant(const Span<byte>& v)
: Type(VariantType::Blob)
{
AsBlob.Length = v.Length();
if (AsBlob.Length > 0)
{
AsBlob.Data = Allocator::Allocate(AsBlob.Length);
Platform::MemoryCopy(AsBlob.Data, v.Get(), AsBlob.Length);
}
else
{
AsBlob.Data = nullptr;
}
}
Variant::Variant(const CommonValue& value)
: Variant()
{
+1
View File
@@ -229,6 +229,7 @@ public:
Variant(Array<Variant, HeapAllocation>&& v);
Variant(const Array<Variant, HeapAllocation>& v);
explicit Variant(const Dictionary<Variant, Variant, HeapAllocation>& v);
explicit Variant(const Span<byte>& v);
explicit Variant(const CommonValue& v);
~Variant();