fix(Foundation): Poco::BasicMemoryStreamBuf is missing seekpos() #4492

This commit is contained in:
Günter Obiltschnig 2024-03-22 08:53:14 +01:00
parent 77eb14eebd
commit 5fec3deeb9
2 changed files with 20 additions and 0 deletions

View File

@ -141,6 +141,12 @@ public:
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()
{
return 0;

View File

@ -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);
@ -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);