2012-02-27 06:28:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-20 02:23:35 +00:00
|
|
|
#include <Core/Types.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#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.
|
2018-11-30 15:36:41 +00:00
|
|
|
* 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;
|
2018-08-20 02:23:35 +00:00
|
|
|
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
|
|
|
|
|
|
|
}
|