ClickHouse/dbms/IO/LimitReadBuffer.h

29 lines
616 B
C++
Raw Normal View History

2012-02-27 06:28:20 +00:00
#pragma once
#include <Core/Types.h>
#include <IO/ReadBuffer.h>
2012-02-27 06:28:20 +00:00
namespace DB
{
2017-08-14 04:26:52 +00:00
/** 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.
2012-02-27 06:28:20 +00:00
*/
2017-08-14 04:30:37 +00:00
class LimitReadBuffer : public ReadBuffer
{
private:
ReadBuffer & in;
2019-02-10 15:17:45 +00:00
UInt64 limit;
bool throw_exception;
std::string exception_message;
2017-08-14 03:38:32 +00:00
2017-08-14 04:42:04 +00:00
bool nextImpl() override;
2017-08-14 03:38:32 +00:00
2017-08-14 04:30:37 +00:00
public:
2019-08-03 11:02:40 +00:00
LimitReadBuffer(ReadBuffer & in_, UInt64 limit_, bool throw_exception_, std::string exception_message_ = {});
2017-08-14 04:42:04 +00:00
~LimitReadBuffer() override;
2017-08-14 04:30:37 +00:00
};
2012-02-27 06:28:20 +00:00
}