Created
January 31, 2021 09:00
-
-
Save feliwir/be1322782ea0cf3260372697c9eccafe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <Filesystem.h> | |
#include <libsystem/Common.h> | |
#include <libutils/RefPtr.h> | |
class StreamReader : public RefPtr<StreamReader> | |
{ | |
public: | |
virtual size_t length() = 0; | |
virtual size_t position() = 0; | |
virtual bool can_seek() { return false; } | |
virtual size_t read(void *buffer, size_t size) = 0; | |
virtual size_t seek(size_t pos, Whence whence) = 0; | |
virtual uint8_t read_byte() | |
{ | |
uint8_t result; | |
assert(read(&result, 1)); | |
return result; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <libsystem/Common.h> | |
#include <libutils/RefPtr.h> | |
class StreamWriter : public RefPtr<StreamWriter> | |
{ | |
public: | |
virtual size_t length() = 0; | |
virtual size_t position() = 0; | |
virtual void flush() = 0; | |
virtual void write(const void *buffer, size_t size) = 0; | |
virtual void write_byte(uint8_t v) | |
{ | |
write(&v, 1); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment