#include "Def.h"
#include "Generated.h"

namespace Generated
{
    bool Save(const KnownType::Enum* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            auto val = (int32_t)obj[i];
            isOk = Save(&val, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(KnownType::Enum* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            int32_t& val = (int32_t&)obj[i];
            isOk = Load(&val, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Test* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].Number, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Test* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].Number, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Texture* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].Width, 1, serializer) && isOk;
            isOk = Save(&obj[i].Height, 1, serializer) && isOk;
            isOk = Save(obj[i].StrTest, 3, serializer) && isOk;
            isOk = Save(&obj[i].T, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Texture* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].Width, 1, serializer) && isOk;
            isOk = Load(&obj[i].Height, 1, serializer) && isOk;
            isOk = Load(obj[i].StrTest, 3, serializer) && isOk;
            isOk = Load(&obj[i].T, 1, serializer) && isOk;
        }
        return isOk;
    }
}
