Skip to content

Commit

Permalink
fix(Foundation): Poco::BasicMemoryStreamBuf is missing seekpos() #4492
Browse files Browse the repository at this point in the history
  • Loading branch information
obiltschnig committed Mar 22, 2024
1 parent 77eb14e commit 5fec3de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Foundation/include/Poco/MemoryStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ class BasicMemoryStreamBuf: public std::basic_streambuf<ch, tr>

return newoff;
}

virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
{
const off_type off = pos;
return seekoff(off, std::ios::beg, which);
}

virtual int sync()
{
Expand Down
14 changes: 14 additions & 0 deletions Foundation/testsuite/src/MemoryStreamTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ void MemoryStreamTest::testInputSeek()
assertTrue (istr.good());
assertTrue (9 == istr.tellg());


istr.seekg(5);
assertTrue (istr.good());
assertTrue (5 == istr.tellg());
istr >> c;
assertTrue (c == '6');


{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
istr2.seekg(10, std::ios_base::beg);
Expand Down Expand Up @@ -337,6 +345,12 @@ void MemoryStreamTest::testOutputSeek()
assertTrue (ostr.good());
assertTrue (9 == ostr.tellp());


ostr.seekp(5);
assertTrue (ostr.good());
assertTrue (5 == ostr.tellp());


{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(10, std::ios_base::beg);
Expand Down

0 comments on commit 5fec3de

Please sign in to comment.