aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/streams.h
diff options
context:
space:
mode:
authorPaul Gilbert2019-10-05 18:39:23 -0700
committerPaul Gilbert2019-10-05 18:39:23 -0700
commit8ab36786a4caa4033d9bb6d27b5fd8e0224fbdf2 (patch)
tree507c3289d4d2e6a4f07e0b8a9e9ad5fd1b4539d1 /engines/glk/streams.h
parent2365721b23474d5775075b26a694125a9c89f8b3 (diff)
downloadscummvm-rg350-8ab36786a4caa4033d9bb6d27b5fd8e0224fbdf2.tar.gz
scummvm-rg350-8ab36786a4caa4033d9bb6d27b5fd8e0224fbdf2.tar.bz2
scummvm-rg350-8ab36786a4caa4033d9bb6d27b5fd8e0224fbdf2.zip
GLK: Splitting bulk of FileStream up into an IOStream base class
Diffstat (limited to 'engines/glk/streams.h')
-rw-r--r--engines/glk/streams.h61
1 files changed, 51 insertions, 10 deletions
diff --git a/engines/glk/streams.h b/engines/glk/streams.h
index 2d6d48f1e1..df0d5df738 100644
--- a/engines/glk/streams.h
+++ b/engines/glk/streams.h
@@ -432,16 +432,13 @@ public:
};
/**
- * Implements a file stream
+ * Base class for I/O streams
*/
-class FileStream : public Stream {
+class IOStream : public Stream {
private:
- Common::File _file;
- Common::OutSaveFile *_outFile;
- Common::InSaveFile *_inFile;
Common::SeekableReadStream *_inStream;
+ Common::WriteStream *_outStream;
uint _lastOp; ///< 0, filemode_Write, or filemode_Read
- bool _textFile;
private:
/**
* Ensure the stream is ready for the given operation
@@ -457,16 +454,40 @@ private:
* Get a UTF8 character
*/
int getCharUtf8();
+protected:
+ bool _textFile;
public:
/**
* Constructor
*/
- FileStream(Streams *streams, frefid_t fref, uint fmode, uint rock, bool unicode);
+ IOStream(Streams *streams, bool readable, bool writable, uint rock, bool unicode) :
+ Stream(streams, readable, writable, rock, unicode) {}
+ IOStream(Streams *streams, uint rock = 0) : Stream(streams, false, false, rock, false),
+ _inStream(nullptr), _outStream(nullptr), _lastOp(0), _textFile(false) {}
+ IOStream(Streams *streams, Common::SeekableReadStream *inStream, uint rock = 0) :
+ Stream(streams, true, false, rock, false), _inStream(inStream), _outStream(nullptr), _lastOp(0), _textFile(false) {}
+ IOStream(Streams *streams, Common::WriteStream *outStream, uint rock = 0) :
+ Stream(streams, false, true, rock, false), _inStream(nullptr), _outStream(outStream), _lastOp(0), _textFile(false) {}
+
+ /**
+ * Sets the stream to use
+ */
+ void setStream(Common::SeekableReadStream *rs) {
+ _inStream = rs;
+ _outStream = nullptr;
+ _readable = true;
+ _writable = false;
+ }
/**
- * Destructor
+ * Sets the stream to use
*/
- virtual ~FileStream();
+ void setStream(Common::WriteStream *ws) {
+ _inStream = nullptr;
+ _outStream = ws;
+ _readable = false;
+ _writable = true;
+ }
/**
* Write a character
@@ -525,7 +546,7 @@ public:
/**
* Cast a stream to a ScummVM write stream
*/
- virtual operator Common::WriteStream *() const override { return _outFile; }
+ virtual operator Common::WriteStream *() const override { return _outStream; }
/**
* Cast a stream to a ScummVM read stream
@@ -534,6 +555,26 @@ public:
};
/**
+ * Implements a file stream
+ */
+class FileStream : public IOStream {
+private:
+ Common::File _file;
+ Common::InSaveFile *_inSave;
+ Common::OutSaveFile *_outSave;
+public:
+ /**
+ * Constructor
+ */
+ FileStream(Streams *streams, frefid_t fref, uint fmode, uint rock, bool unicode);
+
+ /**
+ * Destructor
+ */
+ virtual ~FileStream();
+};
+
+/**
* Streams manager
*/
class Streams {