UESaveFile/Serialisers: make types() return an ArrayView of Strings.
It's the best way to avoid dangling views for now.
This commit is contained in:
parent
fdb7567aea
commit
88afaaceec
16 changed files with 27 additions and 30 deletions
|
@ -238,10 +238,8 @@ auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr>
|
|||
}
|
||||
|
||||
auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser* {
|
||||
!Utility::Debug{};
|
||||
for(auto& item : _serialisers) {
|
||||
for(auto serialiser_type : item->types()) {
|
||||
Utility::Debug{} << serialiser_type;
|
||||
if(item_type == serialiser_type) {
|
||||
return item.get();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class AbstractUnrealCollectionPropertySerialiser {
|
|||
|
||||
virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
|
||||
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0;
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
|
||||
|
||||
virtual auto deserialise(Containers::StringView name, Containers::StringView type,
|
||||
UnsignedLong value_length, UnsignedInt count, BinaryReader& reader,
|
||||
|
|
|
@ -37,7 +37,7 @@ class AbstractUnrealPropertySerialiser {
|
|||
|
||||
virtual ~AbstractUnrealPropertySerialiser() = default;
|
||||
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0;
|
||||
virtual auto types() -> Containers::ArrayView<const Containers::String> = 0;
|
||||
|
||||
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "BoolPropertySerialiser.h"
|
||||
|
||||
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"BoolProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"BoolProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<BoolPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "BytePropertySerialiser.h"
|
||||
|
||||
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"ByteProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"ByteProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<BytePropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "EnumPropertySerialiser.h"
|
||||
|
||||
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"EnumProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"EnumProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<EnumPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
|
||||
#include "FloatPropertySerialiser.h"
|
||||
|
||||
|
||||
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"FloatProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"FloatProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<FloatPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "StringPropertySerialiser.h"
|
||||
|
||||
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit,
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit,
|
||||
{"NameProperty"_s, "StrProperty"_s,
|
||||
"SoftObjectProperty"_s, "ObjectProperty"_s}};
|
||||
return types;
|
||||
|
|
|
@ -27,7 +27,7 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<StringPropertySerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
#include "StructSerialiser.h"
|
||||
|
||||
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::StringView> {
|
||||
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::String> {
|
||||
using namespace Containers::Literals;
|
||||
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"StructProperty"_s}};
|
||||
static const Containers::Array<Containers::String> types{InPlaceInit, {"StructProperty"_s}};
|
||||
return types;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
|
|||
public:
|
||||
using ptr = Containers::Pointer<StructSerialiser>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override;
|
||||
|
||||
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
|
||||
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override;
|
||||
|
|
|
@ -32,15 +32,15 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
|
|||
public:
|
||||
using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>;
|
||||
|
||||
auto types() -> Containers::ArrayView<const Containers::StringView> override {
|
||||
static const Containers::Array<Containers::StringView> types = []{
|
||||
Containers::Array<Containers::StringView> array;
|
||||
auto types() -> Containers::ArrayView<const Containers::String> override {
|
||||
static const Containers::Array<Containers::String> types = []{
|
||||
Containers::Array<Containers::String> array;
|
||||
Containers::Pointer<T> p(new T);
|
||||
if(std::is_base_of<StructProperty, T>::value) {
|
||||
array = Containers::Array<Containers::StringView>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
|
||||
}
|
||||
else {
|
||||
array = Containers::Array<Containers::StringView>{InPlaceInit, {p->propertyType}};
|
||||
array = Containers::Array<Containers::String>{InPlaceInit, {p->propertyType}};
|
||||
}
|
||||
return array;
|
||||
}();
|
||||
|
|
Loading…
Reference in a new issue