Files
o3de/Code/Legacy/CryCommon/SimpleSerialize.h
T
Artur K 2a2847b15d Legacy code cleanup - part 3 (#3903)
* Legacy cleanup - part 3

Not much is left that can be easily removed,
so I think this will be last cleanup before the legacy functionality is replaced.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* fix windows build, remove a few more things, re-add one file

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove legacy RenderBus + more cleanups

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Remove MaterialOwnerBus.h

Clean-up in Cry_Matrix34/33

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
2021-09-07 12:14:16 -06:00

109 lines
2.6 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include "TimeValue.h"
#include <ISerialize.h> // <> required for Interfuscator
template<bool READING, ESerializationTarget TARGET>
class CSimpleSerializeImpl
{
public:
CSimpleSerializeImpl()
: m_failed(false)
{
}
ILINE bool IsReading() const
{
return READING;
}
ILINE void BeginGroup(const char* szName)
{
}
ILINE void EndGroup()
{
}
ILINE bool Ok() const
{
return !m_failed;
}
protected:
ILINE void Failed()
{
m_failed = true;
}
private:
bool m_failed;
};
template<class Impl>
class CSimpleSerialize : public ISerialize
{
public:
ILINE CSimpleSerialize(Impl& impl)
: m_impl(impl)
{
}
void BeginGroup(const char* szName)
{
m_impl.BeginGroup(szName);
}
bool BeginOptionalGroup(const char* szName, bool condition)
{
return m_impl.BeginOptionalGroup(szName, condition);
}
void EndGroup()
{
m_impl.EndGroup();
}
bool IsReading() const
{
return m_impl.IsReading();
}
void WriteStringValue(const char* name, SSerializeString& value)
{
m_impl.Value(name, value);
}
void ReadStringValue(const char* name, SSerializeString& curValue)
{
m_impl.Value(name, curValue);
}
#define SERIALIZATION_TYPE(T) \
void Value(const char* name, T& x) override \
{ \
m_impl.Value(name, x); \
}
#include "SerializationTypes.h"
#undef SERIALIZATION_TYPE
Impl* GetInnerImpl()
{
return &m_impl;
}
protected:
Impl& m_impl;
};
//////////////////////////////////////////////////////////////////////////
// Support serialization with default values,
// Require Implementation serialization stub to have Value() method returning boolean.
//////////////////////////////////////////////////////////////////////////
template<class Impl>
using CSimpleSerializeWithDefaults = CSimpleSerialize<Impl>;