Core: Merge InputStream and OutputStream to Stream
Remove serialization support from Stream Former-commit-id: 7a761e4fcd07cab561f13e4709c4492ed18da88a
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
|
||||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/OutputStream.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
||||
@@ -59,6 +59,13 @@ namespace Nz
|
||||
return m_array.back();
|
||||
}
|
||||
|
||||
inline void ByteArray::Clear(bool keepBuffer)
|
||||
{
|
||||
m_array.clear();
|
||||
if (!keepBuffer)
|
||||
m_array.shrink_to_fit();
|
||||
}
|
||||
|
||||
inline ByteArray::iterator ByteArray::Erase(const_iterator pos)
|
||||
{
|
||||
return m_array.erase(pos);
|
||||
|
||||
@@ -80,11 +80,12 @@ namespace Nz
|
||||
OpenMode_Append = 0x01, // Empêche l'écriture sur la partie déjà existante et met le curseur à la fin
|
||||
OpenMode_Lock = 0x02, // Empêche le fichier d'être modifié tant qu'il est ouvert
|
||||
OpenMode_ReadOnly = 0x04, // Ouvre uniquement en lecture
|
||||
OpenMode_ReadWrite = 0x08, // Ouvre en lecture/écriture
|
||||
OpenMode_Text = 0x10, // Ouvre en mode texte
|
||||
OpenMode_Truncate = 0x20, // Créé le fichier s'il n'existe pas et le vide s'il existe
|
||||
OpenMode_WriteOnly = 0x40, // Ouvre uniquement en écriture, créé le fichier s'il n'existe pas
|
||||
|
||||
OpenMode_ReadWrite = OpenMode_ReadOnly | OpenMode_WriteOnly, // Ouvre en lecture/écriture
|
||||
|
||||
OpenMode_Max = OpenMode_WriteOnly
|
||||
};
|
||||
|
||||
@@ -173,7 +174,8 @@ namespace Nz
|
||||
{
|
||||
StreamOption_None = 0,
|
||||
|
||||
StreamOption_Text = 0x1,
|
||||
StreamOption_Sequential = 0x1,
|
||||
StreamOption_Text = 0x2,
|
||||
|
||||
StreamOption_Max = StreamOption_Text*2-1
|
||||
};
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/OutputStream.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
|
||||
@@ -27,7 +26,7 @@ namespace Nz
|
||||
{
|
||||
class FileImpl;
|
||||
|
||||
class NAZARA_CORE_API File : public InputStream, public OutputStream
|
||||
class NAZARA_CORE_API File : public Stream
|
||||
{
|
||||
public:
|
||||
File();
|
||||
@@ -47,8 +46,6 @@ namespace Nz
|
||||
|
||||
bool Exists() const;
|
||||
|
||||
void Flush() override;
|
||||
|
||||
time_t GetCreationTime() const;
|
||||
UInt64 GetCursorPos() const override;
|
||||
String GetDirectory() const override;
|
||||
@@ -63,16 +60,12 @@ namespace Nz
|
||||
bool Open(unsigned int openMode = OpenMode_Current);
|
||||
bool Open(const String& filePath, unsigned int openMode = OpenMode_Current);
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size) override;
|
||||
bool Rename(const String& newFilePath);
|
||||
|
||||
bool SetCursorPos(CursorPosition pos, Int64 offset = 0);
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
bool SetFile(const String& filePath);
|
||||
|
||||
using OutputStream::Write;
|
||||
std::size_t Write(const void* buffer, std::size_t size) override;
|
||||
|
||||
File& operator=(const String& filePath);
|
||||
File& operator=(const File&) = delete;
|
||||
File& operator=(File&& file) noexcept;
|
||||
@@ -96,6 +89,10 @@ namespace Nz
|
||||
private:
|
||||
NazaraMutexAttrib(m_mutex, mutable)
|
||||
|
||||
void FlushStream() override;
|
||||
std::size_t ReadBlock(void* buffer, std::size_t size) override;
|
||||
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
||||
|
||||
String m_filePath;
|
||||
FileImpl* m_impl;
|
||||
};
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
// 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_INPUTSTREAM_HPP
|
||||
#define NAZARA_INPUTSTREAM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API InputStream : virtual public Stream
|
||||
{
|
||||
public:
|
||||
inline InputStream(const InputStream& stream);
|
||||
inline InputStream(InputStream&& stream) noexcept;
|
||||
virtual ~InputStream();
|
||||
|
||||
virtual bool EndOfStream() const = 0;
|
||||
|
||||
virtual UInt64 GetSize() const = 0;
|
||||
|
||||
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||
virtual String ReadLine(unsigned int lineSize = 0);
|
||||
|
||||
template<typename T>
|
||||
InputStream& operator>>(T& value);
|
||||
|
||||
inline InputStream& operator=(const InputStream& stream);
|
||||
inline InputStream& operator=(InputStream&& stream) noexcept;
|
||||
|
||||
protected:
|
||||
inline InputStream();
|
||||
|
||||
UnserializationContext m_unserializationContext;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/InputStream.inl>
|
||||
|
||||
#endif // NAZARA_INPUTSTREAM_HPP
|
||||
@@ -1,63 +0,0 @@
|
||||
// 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/Error.hpp>
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline InputStream::InputStream() :
|
||||
Stream(OpenMode_Current)
|
||||
{
|
||||
m_unserializationContext.stream = this;
|
||||
}
|
||||
|
||||
inline InputStream::InputStream(const InputStream& stream) :
|
||||
Stream(stream),
|
||||
m_unserializationContext(stream.m_unserializationContext)
|
||||
{
|
||||
m_unserializationContext.stream = this;
|
||||
}
|
||||
|
||||
inline InputStream::InputStream(InputStream&& stream) noexcept :
|
||||
Stream(std::move(stream)),
|
||||
m_unserializationContext(std::move(stream.m_unserializationContext))
|
||||
{
|
||||
m_unserializationContext.stream = this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
InputStream& InputStream::operator>>(T& value)
|
||||
{
|
||||
m_unserializationContext.endianness = m_dataEndianness; //< In case m_dataEndianness changed
|
||||
|
||||
if (!Unserialize(m_unserializationContext, &value))
|
||||
NazaraError("Failed to unserialize value");
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline InputStream& InputStream::operator=(const InputStream& stream)
|
||||
{
|
||||
Stream::operator=(stream);
|
||||
|
||||
m_unserializationContext = stream.m_unserializationContext;
|
||||
m_unserializationContext.stream = this;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline InputStream& InputStream::operator=(InputStream&& stream) noexcept
|
||||
{
|
||||
Stream::operator=(std::move(stream));
|
||||
|
||||
m_unserializationContext = std::move(stream.m_unserializationContext);
|
||||
m_unserializationContext.stream = this;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/OutputStream.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API MemoryStream : public InputStream, public OutputStream
|
||||
class NAZARA_CORE_API MemoryStream : public Stream
|
||||
{
|
||||
public:
|
||||
MemoryStream();
|
||||
@@ -27,23 +26,22 @@ namespace Nz
|
||||
|
||||
bool EndOfStream() const override;
|
||||
|
||||
void Flush() override;
|
||||
|
||||
const ByteArray& GetBuffer() const;
|
||||
const UInt8* GetData() const;
|
||||
UInt64 GetCursorPos() const override;
|
||||
UInt64 GetSize() const override;
|
||||
|
||||
std::size_t Read(void* buffer, std::size_t size) override;
|
||||
|
||||
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:
|
||||
void FlushStream() override;
|
||||
std::size_t ReadBlock(void* buffer, std::size_t size) override;
|
||||
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
||||
|
||||
ByteArray m_buffer;
|
||||
UInt64 m_pos;
|
||||
};
|
||||
@@ -55,6 +53,6 @@ namespace Nz
|
||||
NAZARA_CORE_API bool Unserialize(UnserializationContext& context, String* string);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/MemoryStream.inl>
|
||||
|
||||
#endif // NAZARA_MEMORYSTREAM_HPP
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#define NAZARA_MEMORYVIEW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API MemoryView : public InputStream
|
||||
class NAZARA_CORE_API MemoryView : public Stream
|
||||
{
|
||||
public:
|
||||
MemoryView(const void* ptr, UInt64 size);
|
||||
@@ -25,14 +25,16 @@ namespace Nz
|
||||
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:
|
||||
void FlushStream() override;
|
||||
std::size_t ReadBlock(void* buffer, std::size_t size) override;
|
||||
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
|
||||
|
||||
const UInt8* m_ptr;
|
||||
UInt64 m_pos;
|
||||
UInt64 m_size;
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// 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_OUTPUTSTREAM_HPP
|
||||
#define NAZARA_OUTPUTSTREAM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Serialization.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ByteArray;
|
||||
class String;
|
||||
|
||||
class NAZARA_CORE_API OutputStream : virtual public Stream
|
||||
{
|
||||
public:
|
||||
inline OutputStream(const OutputStream& stream);
|
||||
inline OutputStream(OutputStream&& stream) noexcept;
|
||||
virtual ~OutputStream();
|
||||
|
||||
virtual void Flush() = 0;
|
||||
|
||||
bool Write(const ByteArray& byteArray);
|
||||
bool Write(const String& string);
|
||||
virtual std::size_t Write(const void* buffer, std::size_t size) = 0;
|
||||
|
||||
template<typename T>
|
||||
OutputStream& operator<<(const T& value);
|
||||
|
||||
inline OutputStream& operator=(const OutputStream& stream);
|
||||
inline OutputStream& operator=(OutputStream&& stream) noexcept;
|
||||
|
||||
protected:
|
||||
inline OutputStream();
|
||||
|
||||
SerializationContext m_serializationContext;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/OutputStream.inl>
|
||||
|
||||
#endif // NAZARA_OUTPUTSTREAM_HPP
|
||||
@@ -1,63 +0,0 @@
|
||||
// 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/Error.hpp>
|
||||
#include <utility>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline OutputStream::OutputStream() :
|
||||
Stream(OpenMode_Current)
|
||||
{
|
||||
m_serializationContext.stream = this;
|
||||
}
|
||||
|
||||
inline OutputStream::OutputStream(const OutputStream& stream) :
|
||||
Stream(stream),
|
||||
m_serializationContext(stream.m_serializationContext)
|
||||
{
|
||||
m_serializationContext.stream = this;
|
||||
}
|
||||
|
||||
inline OutputStream::OutputStream(OutputStream&& stream) noexcept :
|
||||
Stream(std::move(stream)),
|
||||
m_serializationContext(std::move(stream.m_serializationContext))
|
||||
{
|
||||
m_serializationContext.stream = this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
OutputStream& OutputStream::operator<<(const T& value)
|
||||
{
|
||||
m_serializationContext.endianness = m_dataEndianness; //< In case m_dataEndianness changed
|
||||
|
||||
if (!Serialize(m_serializationContext, value))
|
||||
NazaraError("Failed to serialize value");
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline OutputStream& OutputStream::operator=(const OutputStream& stream)
|
||||
{
|
||||
Stream::operator=(stream);
|
||||
|
||||
m_serializationContext = stream.m_serializationContext;
|
||||
m_serializationContext.stream = this;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline OutputStream& OutputStream::operator=(OutputStream&& stream) noexcept
|
||||
{
|
||||
Stream::operator=(std::move(stream));
|
||||
|
||||
m_serializationContext = std::move(stream.m_serializationContext);
|
||||
m_serializationContext.stream = this;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class InputStream;
|
||||
class Stream;
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
class ResourceLoader
|
||||
@@ -27,8 +27,8 @@ namespace Nz
|
||||
using ExtensionGetter = bool (*)(const String& extension);
|
||||
using FileLoader = bool (*)(Type* resource, const String& filePath, const Parameters& parameters);
|
||||
using MemoryLoader = bool (*)(Type* resource, const void* data, std::size_t size, const Parameters& parameters);
|
||||
using StreamChecker = Ternary (*)(InputStream& stream, const Parameters& parameters);
|
||||
using StreamLoader = bool (*)(Type* resource, InputStream& stream, const Parameters& parameters);
|
||||
using StreamChecker = Ternary (*)(Stream& stream, const Parameters& parameters);
|
||||
using StreamLoader = bool (*)(Type* resource, Stream& stream, const Parameters& parameters);
|
||||
|
||||
ResourceLoader() = delete;
|
||||
~ResourceLoader() = delete;
|
||||
@@ -37,7 +37,7 @@ namespace Nz
|
||||
|
||||
static bool LoadFromFile(Type* resource, const String& filePath, const Parameters& parameters = Parameters());
|
||||
static bool LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters = Parameters());
|
||||
static bool LoadFromStream(Type* resource, InputStream& stream, const Parameters& parameters = Parameters());
|
||||
static bool LoadFromStream(Type* resource, Stream& stream, const Parameters& parameters = Parameters());
|
||||
|
||||
static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr);
|
||||
static void UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr);
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -199,7 +199,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename Type, typename Parameters>
|
||||
bool ResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, InputStream& stream, const Parameters& parameters)
|
||||
bool ResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, Stream& stream, const Parameters& parameters)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
if (!parameters.IsValid())
|
||||
|
||||
@@ -15,18 +15,17 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class InputStream;
|
||||
class OutputStream;
|
||||
class Stream;
|
||||
|
||||
struct SerializationContext
|
||||
{
|
||||
OutputStream* stream;
|
||||
Stream* stream;
|
||||
Endianness endianness;
|
||||
};
|
||||
|
||||
struct UnserializationContext
|
||||
{
|
||||
InputStream* stream;
|
||||
Stream* stream;
|
||||
Endianness endianness;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class ByteArray;
|
||||
class String; //< Do not include String.hpp in this file
|
||||
|
||||
class NAZARA_CORE_API Stream
|
||||
@@ -22,19 +23,33 @@ namespace Nz
|
||||
Stream(Stream&&) = default;
|
||||
virtual ~Stream();
|
||||
|
||||
virtual bool EndOfStream() const = 0;
|
||||
|
||||
inline void EnableTextMode(bool textMode);
|
||||
|
||||
inline void Flush();
|
||||
|
||||
virtual UInt64 GetCursorPos() const = 0;
|
||||
virtual String GetDirectory() const;
|
||||
virtual String GetPath() const;
|
||||
inline Endianness GetDataEndianness() const;
|
||||
inline UInt32 GetOpenMode() const;
|
||||
inline UInt32 GetStreamOptions() const;
|
||||
|
||||
virtual UInt64 GetSize() const = 0;
|
||||
|
||||
inline std::size_t Read(void* buffer, std::size_t size);
|
||||
virtual String ReadLine(unsigned int lineSize = 0);
|
||||
|
||||
inline bool IsReadable() const;
|
||||
inline bool IsSequential() const;
|
||||
inline bool IsTextModeEnabled() const;
|
||||
inline bool IsWritable() const;
|
||||
|
||||
virtual bool SetCursorPos(UInt64 offset) = 0;
|
||||
inline void SetDataEndianness(Endianness endiannes);
|
||||
inline void SetStreamOptions(UInt32 options);
|
||||
|
||||
bool Write(const ByteArray& byteArray);
|
||||
bool Write(const String& string);
|
||||
inline std::size_t Write(const void* buffer, std::size_t size);
|
||||
|
||||
Stream& operator=(const Stream&) = default;
|
||||
Stream& operator=(Stream&&) = default;
|
||||
@@ -42,7 +57,10 @@ namespace Nz
|
||||
protected:
|
||||
inline Stream(UInt32 openMode);
|
||||
|
||||
Endianness m_dataEndianness;
|
||||
virtual void FlushStream() = 0;
|
||||
virtual std::size_t ReadBlock(void* buffer, std::size_t size) = 0;
|
||||
virtual std::size_t WriteBlock(const void* buffer, std::size_t size) = 0;
|
||||
|
||||
UInt32 m_openMode;
|
||||
UInt32 m_streamOptions;
|
||||
};
|
||||
|
||||
@@ -2,18 +2,29 @@
|
||||
// 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/Error.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline Stream::Stream(UInt32 openMode) :
|
||||
m_dataEndianness(Endianness_Unknown),
|
||||
m_openMode(openMode),
|
||||
m_streamOptions(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline Endianness Stream::GetDataEndianness() const
|
||||
inline void Stream::EnableTextMode(bool textMode)
|
||||
{
|
||||
return m_dataEndianness;
|
||||
if (textMode)
|
||||
m_streamOptions |= StreamOption_Text;
|
||||
else
|
||||
m_streamOptions &= ~StreamOption_Text;
|
||||
}
|
||||
|
||||
inline void Stream::Flush()
|
||||
{
|
||||
NazaraAssert(IsWritable(), "Stream is not writable");
|
||||
|
||||
FlushStream();
|
||||
}
|
||||
|
||||
inline UInt32 Stream::GetOpenMode() const
|
||||
@@ -28,21 +39,36 @@ namespace Nz
|
||||
|
||||
inline bool Stream::IsReadable() const
|
||||
{
|
||||
return m_openMode & OpenMode_ReadOnly || m_openMode & OpenMode_ReadWrite;
|
||||
return (m_openMode & OpenMode_ReadOnly) != 0;
|
||||
}
|
||||
|
||||
inline bool Stream::IsSequential() const
|
||||
{
|
||||
return (m_streamOptions & StreamOption_Sequential) != 0;
|
||||
}
|
||||
|
||||
inline bool Stream::IsTextModeEnabled() const
|
||||
{
|
||||
return (m_streamOptions & StreamOption_Text) != 0;
|
||||
}
|
||||
|
||||
inline bool Stream::IsWritable() const
|
||||
{
|
||||
return m_openMode & OpenMode_ReadWrite || m_openMode & OpenMode_WriteOnly;
|
||||
return (m_openMode & OpenMode_WriteOnly) != 0;
|
||||
}
|
||||
|
||||
inline void Stream::SetDataEndianness(Endianness endiannes)
|
||||
inline std::size_t Stream::Read(void* buffer, std::size_t size)
|
||||
{
|
||||
m_dataEndianness = endiannes;
|
||||
NazaraAssert(IsReadable(), "Stream is not readable");
|
||||
|
||||
return ReadBlock(buffer, size);
|
||||
}
|
||||
|
||||
inline void Stream::SetStreamOptions(UInt32 options)
|
||||
inline std::size_t Stream::Write(const void* buffer, std::size_t size)
|
||||
{
|
||||
m_streamOptions = options;
|
||||
NazaraAssert(IsWritable(), "Stream is not writable");
|
||||
|
||||
return WriteBlock(buffer, size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user