Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created March 15, 2015 12:18
Show Gist options
  • Save rightfold/ed3681d9494a75e585de to your computer and use it in GitHub Desktop.
Save rightfold/ed3681d9494a75e585de to your computer and use it in GitHub Desktop.
class Stream {
public:
Stream(std::vector<unsigned char> const& data)
: data(&data) { }
void seek(std::size_t newOffset) {
if (newOffset >= data->size()) {
throw "fuck";
}
offset = newOffset;
}
unsigned char read() {
seek(offset + 1);
return data->at(offset);
}
private:
std::size_t offset;
std::vector<unsigned char> const* data;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment