ClickHouse/dbms/src/IO/LimitReadBuffer.h
Alexey Milovidov c603d270f4 Cleanups #4246
2019-02-10 18:17:45 +03:00

29 lines
612 B
C++

#pragma once
#include <Core/Types.h>
#include <IO/ReadBuffer.h>
namespace DB
{
/** Allows to read from another ReadBuffer no more than the specified number of bytes.
* Note that the nested ReadBuffer may read slightly more data internally to fill its buffer.
*/
class LimitReadBuffer : public ReadBuffer
{
private:
ReadBuffer & in;
UInt64 limit;
bool throw_exception;
std::string exception_message;
bool nextImpl() override;
public:
LimitReadBuffer(ReadBuffer & in, UInt64 limit, bool throw_exception, std::string exception_message = {});
~LimitReadBuffer() override;
};
}