bsnes/nall/stream/vector.hpp
Tim Allen f2a416aea9 Update to v095r11 release.
byuu says:

Changelog:
- SFC: "uint8 read(uint addr)" -> "uint8 read(uint addr, uint8 data)"
- hiro: mHorizontalLayout::setGeometry() return value
- hiro/GTK: ListView,TreeView::setFocused() does not grab focus of first
  item

Notes:
- nall/windows/utf8.hpp needs using uint = unsigned; at the top to
  compile
- sfc/balanced, sfc/performance won't compile yet

Seems Cx4 games broke a while back. Not from this WIP, either. I'll go
back and find out what's wrong now.
2015-12-14 20:41:06 +11:00

41 lines
1.2 KiB
C++

#ifndef NALL_STREAM_VECTOR_HPP
#define NALL_STREAM_VECTOR_HPP
#include <nall/stream/stream.hpp>
#include <nall/vector.hpp>
namespace nall {
struct vectorstream : stream {
using stream::read;
using stream::write;
vectorstream(vector<uint8>& memory) : memory(memory), pwritable(true) {}
vectorstream(const vector<uint8>& memory) : memory((vector<uint8>&)memory), pwritable(false) {}
auto seekable() const -> bool { return true; }
auto readable() const -> bool { return true; }
auto writable() const -> bool { return pwritable; }
auto randomaccess() const -> bool { return true; }
auto data() const -> uint8* { return memory.data(); }
auto size() const -> uint { return memory.size(); }
auto offset() const -> uint { return poffset; }
auto seek(unsigned offset) const -> void { poffset = offset; }
auto read() const -> uint8 { return memory[poffset++]; }
auto write(uint8 data) const -> void { memory[poffset++] = data; }
auto read(uint offset) const -> uint8 { return memory[offset]; }
auto write(uint offset, uint8 data) const -> void { memory[offset] = data; }
protected:
vector<uint8>& memory;
mutable uint poffset = 0;
mutable bool pwritable = false;
};
}
#endif