// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Types/BaseTypes.h"
#define FILESTREAM_BUFFER_SIZE 4096
#define STREAM_MAX_STRING_LENGTH (4*1024) // 4 kB
// Forward declarations
class ReadStream;
class WriteStream;
///
/// Base class for all data streams (memory streams, file streams etc.)
///
class FLAXENGINE_API Stream
{
protected:
bool _hasError;
Stream()
: _hasError(false)
{
}
public:
///
/// Virtual destructor
///
virtual ~Stream()
{
}
public:
///
/// Returns true if error occurred during reading/writing to the stream
///
/// True if error occurred during reading/writing to the stream
virtual bool HasError() const
{
return _hasError;
}
///
/// Returns true if can read data from that stream.
///
/// True if can read, otherwise false.
virtual bool CanRead()
{
return false;
}
///
/// Returns true if can write data to that stream.
///
/// True if can write, otherwise false.
virtual bool CanWrite()
{
return false;
}
public:
///
/// Flush the stream buffers
///
virtual void Flush() = 0;
///
/// Close the stream
///
virtual void Close() = 0;
///
/// Gets length of the stream
///
/// Length of the stream
virtual uint32 GetLength() = 0;
///
/// Gets current position in the stream
///
/// Current position in the stream
virtual uint32 GetPosition() = 0;
///
/// Set new position in the stream
///
/// New position in the stream
virtual void SetPosition(uint32 seek) = 0;
};