21 char* data =
reinterpret_cast<char*
>(
const_cast<std::byte*
>(buffer.data()));
22 this->setg(data, data, data + buffer.size());
28 const spanstreambuf::char_type* ,
30 MT_THROW(
"spanstreambuf is not writable.");
33spanstreambuf::pos_type
35 if ((which & std::ios_base::in) == 0) {
36 return {off_type(-1)};
38 char*
const beg = eback();
39 char*
const cur = gptr();
40 char*
const end = egptr();
43 return (off == 0) ? pos_type(0) : pos_type(off_type(-1));
50 case std::ios_base::beg:
53 case std::ios_base::cur:
56 case std::ios_base::end:
60 return {off_type(-1)};
62 const off_type target = base + off;
63 if (target < 0 || target > (end - beg)) {
64 return {off_type(-1)};
66 setg(beg, beg + target, end);
71 return seekoff(off_type(pos), std::ios_base::beg, which);
83 const int c = is.get();
93 const auto next_c = is.peek();
105 line.push_back(gsl::narrow_cast<char>(c));
#define MT_THROW(...)
Throws a std::runtime_error with a formatted message.
std::istream & GetLineCrossPlatform(std::istream &is, std::string &line)
Reads a line from the input stream, handling line endings for different platforms.
~ispanstream() override
Destructor.
ispanstream(std::span< const std::byte > buffer)
Construct an ispanstream with a buffer.
std::streamsize xsputn(const char_type *s, std::streamsize n) override
Write a sequence of characters to the output buffer.
~spanstreambuf() override
Destructor.
spanstreambuf(std::span< const std::byte > buffer={})
Construct a spanstreambuf with an optional buffer.
pos_type seekoff(off_type off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in) override
Seek to an offset relative to way (begin/cur/end).
pos_type seekpos(pos_type pos, std::ios_base::openmode which=std::ios_base::in) override
Seek to an absolute position from the start of the buffer.