Support advancing & retrieving internal pointer in io::memory_stream
This commit is contained in:
parent
f93383f06d
commit
9a47155284
1 changed files with 18 additions and 0 deletions
|
|
@ -55,6 +55,15 @@ namespace psemek::io
|
||||||
|
|
||||||
std::size_t read(char * p, std::size_t size) override;
|
std::size_t read(char * p, std::size_t size) override;
|
||||||
|
|
||||||
|
void advance(std::size_t n)
|
||||||
|
{
|
||||||
|
if (end_ - begin_ < n)
|
||||||
|
throw io::istream_end{};
|
||||||
|
begin_ += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * data() const { return begin_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char const * begin_ = nullptr;
|
char const * begin_ = nullptr;
|
||||||
char const * end_ = nullptr;
|
char const * end_ = nullptr;
|
||||||
|
|
@ -101,6 +110,15 @@ namespace psemek::io
|
||||||
std::swap(end_, s.end_);
|
std::swap(end_, s.end_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void advance(std::size_t n)
|
||||||
|
{
|
||||||
|
if (end_ - begin_ < n)
|
||||||
|
throw io::istream_end{};
|
||||||
|
begin_ += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * data() const { return begin_; }
|
||||||
|
|
||||||
std::size_t write(char const * p, std::size_t size) override;
|
std::size_t write(char const * p, std::size_t size) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue