ClickHouse/src/IO/ReadBufferFromFileDecorator.cpp

49 lines
891 B
C++
Raw Normal View History

2021-04-20 18:29:03 +00:00
#include <IO/ReadBufferFromFileDecorator.h>
namespace DB
{
ReadBufferFromFileDecorator::ReadBufferFromFileDecorator(std::unique_ptr<SeekableReadBuffer> impl_)
2021-04-20 18:29:03 +00:00
: impl(std::move(impl_))
{
swap(*impl);
}
std::string ReadBufferFromFileDecorator::getFileName() const
{
if (ReadBufferFromFileBase * buffer = dynamic_cast<ReadBufferFromFileBase*>(impl.get()))
return buffer->getFileName();
return std::string();
2021-04-20 18:29:03 +00:00
}
off_t ReadBufferFromFileDecorator::getPosition()
{
swap(*impl);
auto position = impl->getPosition();
swap(*impl);
return position;
}
off_t ReadBufferFromFileDecorator::seek(off_t off, int whence)
{
swap(*impl);
auto result = impl->seek(off, whence);
swap(*impl);
return result;
}
bool ReadBufferFromFileDecorator::nextImpl()
{
swap(*impl);
auto result = impl->next();
swap(*impl);
return result;
}
}