1 | #pragma once |
2 | |
3 | #include <Core/Types.h> |
4 | #include <IO/ReadBuffer.h> |
5 | |
6 | |
7 | namespace DB |
8 | { |
9 | |
10 | /** Allows to read from another ReadBuffer no more than the specified number of bytes. |
11 | * Note that the nested ReadBuffer may read slightly more data internally to fill its buffer. |
12 | */ |
13 | class LimitReadBuffer : public ReadBuffer |
14 | { |
15 | private: |
16 | ReadBuffer & in; |
17 | UInt64 limit; |
18 | bool throw_exception; |
19 | std::string exception_message; |
20 | |
21 | bool nextImpl() override; |
22 | |
23 | public: |
24 | LimitReadBuffer(ReadBuffer & in_, UInt64 limit_, bool throw_exception_, std::string exception_message_ = {}); |
25 | ~LimitReadBuffer() override; |
26 | }; |
27 | |
28 | } |
29 | |