wavelength 1.0.0
Loading...
Searching...
No Matches
asyncstream.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "os/binstream.h"
6#include "os/file.h"
7#include "os/string.h"
8
16class AsyncStream : public BinStream {
17public:
26 AsyncStream(const char *pszFile, bool bLittleEndian);
27
34 ~AsyncStream() override;
35
46 bool Ready(int nBytes);
47
56#ifdef VIDEO_STANDARD_PAL
57 void ReadImpl(void *pData, int nBytes) override;
58#else
59 void Read(void *pData, int nBytes) override;
60#endif
61
70#ifdef VIDEO_STANDARD_PAL
71 void WriteImpl(const void *pData, int nBytes) override;
72#else
73 void Write(const void *pData, int nBytes) override;
74#endif
75
82 void Flush() override {
83 }
84
93#ifdef VIDEO_STANDARD_PAL
94 void SeekImpl(int nOffset, SeekType eFrom) override;
95#else
96 void Seek(int nOffset, SeekType eFrom) override;
97#endif
98
106 int Tell() override {
107 return mPosition;
108 }
109
117 const char *GetFileName() const {
118 return mFileName.c_str();
119 }
120
128 bool Eof() override {
129 return mPosition == mSize;
130 }
131
139 bool Fail() override {
140 return mFail != 0;
141 }
142
143private:
144 String mFileName;
145 int mFail;
146 int mPosition;
147 int mSize;
148 char *mBuffer;
149 std::unique_ptr<File> mFile;
150};
AsyncStream(const char *pszFile, bool bLittleEndian)
Open a file and start reading it.
bool Fail() override
Report whether a transfer failed.
Definition asyncstream.h:139
bool Eof() override
Report whether the position is at the end of the file.
Definition asyncstream.h:128
void Flush() override
Do nothing.
Definition asyncstream.h:82
const char * GetFileName() const
Report the file.
Definition asyncstream.h:117
int Tell() override
Report the position.
Definition asyncstream.h:106
void Read(void *pData, int nBytes) override
Read bytes, waiting for them to arrive.
void Write(const void *pData, int nBytes) override
Write bytes.
void Seek(int nOffset, SeekType eFrom) override
Move the position.
bool Ready(int nBytes)
Report whether enough of the file has been read.
~AsyncStream() override
Release the buffer and the file.
SeekType
Origins of Seek().
Definition binstream.h:25
BinStream(bool bLittleEndian)
Construct a stream.
Definition binstream.h:38
Growable text buffer that is also a PrnStream.
Definition string.h:19