blob: bf054d08425cd608ea7bd83fa73f9f8e5735947f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <IO/ReadBuffer.h>
namespace DB
{
namespace
{
template <typename CustomData>
class ReadBufferWrapper : public ReadBuffer
{
public:
ReadBufferWrapper(ReadBuffer & in_, CustomData && custom_data_)
: ReadBuffer(in_.buffer().begin(), in_.buffer().size(), in_.offset()), in(in_), custom_data(std::move(custom_data_))
{
}
private:
ReadBuffer & in;
CustomData custom_data;
bool nextImpl() override
{
in.position() = position();
if (!in.next())
{
set(in.position(), 0);
return false;
}
BufferBase::set(in.buffer().begin(), in.buffer().size(), in.offset());
return true;
}
};
}
std::unique_ptr<ReadBuffer> wrapReadBufferReference(ReadBuffer & ref)
{
return std::make_unique<ReadBufferWrapper<nullptr_t>>(ref, nullptr);
}
std::unique_ptr<ReadBuffer> wrapReadBufferPointer(ReadBufferPtr ptr)
{
return std::make_unique<ReadBufferWrapper<ReadBufferPtr>>(*ptr, ReadBufferPtr{ptr});
}
}
|