Core: Rework Serialization

Former-commit-id: d97eedbd3efc92235e3880ad061a5216fa77ebd7
This commit is contained in:
Lynix
2016-02-03 18:42:19 +01:00
parent f0863d9055
commit e367ec456d
17 changed files with 337 additions and 273 deletions

View File

@@ -0,0 +1,63 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/ByteStream.hpp>
#include <Nazara/Core/MemoryStream.hpp>
#include <Nazara/Core/MemoryView.hpp>
#include <algorithm>
#include <cstring>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
ByteStream::ByteStream(ByteArray* byteArray, UInt32 openMode) :
ByteStream()
{
SetStream(byteArray, openMode);
}
ByteStream::ByteStream(void* ptr, Nz::UInt64 size) :
ByteStream()
{
SetStream(ptr, size);
}
ByteStream::ByteStream(const void* ptr, Nz::UInt64 size) :
ByteStream()
{
SetStream(ptr, size);
}
void ByteStream::SetStream(ByteArray* byteArray, UInt32 openMode)
{
std::unique_ptr<Stream> stream(new MemoryStream(byteArray, openMode));
SetStream(m_ownedStream.get());
// SetStream reset our smart pointer, set it after calling it
m_ownedStream = std::move(stream);
}
void ByteStream::SetStream(void* ptr, Nz::UInt64 size)
{
std::unique_ptr<Stream> stream(new MemoryView(ptr, size));
SetStream(m_ownedStream.get());
// SetStream reset our smart pointer, set it after calling it
m_ownedStream = std::move(stream);
}
void ByteStream::SetStream(const void* ptr, Nz::UInt64 size)
{
std::unique_ptr<Stream> stream(new MemoryView(ptr, size));
SetStream(m_ownedStream.get());
// SetStream reset our smart pointer, set it after calling it
m_ownedStream = std::move(stream);
}
void ByteStream::OnEmptyStream()
{
NazaraError("No stream");
}
}