Core: Rename MemoryStream to MemoryView, add MemoryStream
Former-commit-id: c180d5f34fa7c477f35c4b70ebf7b64e3f35fe3d
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <Nazara/Core/MemoryPool.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/ObjectLibrary.hpp>
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API InputStream : public virtual Stream
|
||||
class NAZARA_CORE_API InputStream : virtual public Stream
|
||||
{
|
||||
public:
|
||||
virtual ~InputStream();
|
||||
|
||||
@@ -9,33 +9,38 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/OutputStream.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API MemoryStream : public InputStream
|
||||
class NAZARA_CORE_API MemoryStream : public InputStream, public OutputStream
|
||||
{
|
||||
public:
|
||||
MemoryStream(const void* ptr, UInt64 size);
|
||||
MemoryStream(const MemoryStream&) = delete;
|
||||
MemoryStream(MemoryStream&&) = delete; ///TODO
|
||||
~MemoryStream();
|
||||
MemoryStream(const void* ptr, unsigned int size);
|
||||
MemoryStream(const MemoryStream&) = default;
|
||||
MemoryStream(MemoryStream&&) = default;
|
||||
~MemoryStream() = default;
|
||||
|
||||
bool EndOfStream() const;
|
||||
bool EndOfStream() const override;
|
||||
|
||||
UInt64 GetCursorPos() const;
|
||||
UInt64 GetSize() const;
|
||||
void Flush() override;
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size);
|
||||
UInt64 GetCursorPos() const override;
|
||||
UInt64 GetSize() const override;
|
||||
|
||||
bool SetCursorPos(UInt64 offset);
|
||||
std::size_t Read(void* buffer, std::size_t size) override;
|
||||
|
||||
MemoryStream& operator=(const MemoryStream&) = delete;
|
||||
MemoryStream& operator=(MemoryStream&&) = delete; ///TODO
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
|
||||
std::size_t Write(const void* buffer, std::size_t size) override;
|
||||
|
||||
MemoryStream& operator=(const MemoryStream&) = default;
|
||||
MemoryStream& operator=(MemoryStream&&) = default;
|
||||
|
||||
private:
|
||||
const UInt8* m_ptr;
|
||||
std::vector<UInt8> m_buffer;
|
||||
UInt64 m_pos;
|
||||
UInt64 m_size;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
42
include/Nazara/Core/MemoryView.hpp
Normal file
42
include/Nazara/Core/MemoryView.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MEMORYVIEW_HPP
|
||||
#define NAZARA_MEMORYVIEW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API MemoryView : public InputStream
|
||||
{
|
||||
public:
|
||||
MemoryView(const void* ptr, UInt64 size);
|
||||
MemoryView(const MemoryView&) = delete;
|
||||
MemoryView(MemoryView&&) = delete; ///TODO
|
||||
~MemoryView() = default;
|
||||
|
||||
bool EndOfStream() const override;
|
||||
|
||||
UInt64 GetCursorPos() const override;
|
||||
UInt64 GetSize() const override;
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size) override;
|
||||
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
|
||||
MemoryView& operator=(const MemoryView&) = delete;
|
||||
MemoryView& operator=(MemoryView&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
const UInt8* m_ptr;
|
||||
UInt64 m_pos;
|
||||
UInt64 m_size;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_MEMORYVIEW_HPP
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API OutputStream : public virtual Stream
|
||||
class NAZARA_CORE_API OutputStream : virtual public Stream
|
||||
{
|
||||
public:
|
||||
virtual ~OutputStream();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -139,7 +139,7 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
MemoryStream stream(data, size);
|
||||
MemoryView stream(data, size);
|
||||
|
||||
bool found = false;
|
||||
for (Loader& loader : Type::s_loaders)
|
||||
|
||||
Reference in New Issue
Block a user