ClickHouse/src/IO/LimitReadBuffer.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.0 KiB
C++
Raw Normal View History

2012-02-27 06:28:20 +00:00
#pragma once
2021-10-02 07:13:14 +00:00
#include <base/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
{
public:
2023-02-22 16:54:35 +00:00
LimitReadBuffer(ReadBuffer & in_, UInt64 limit_, bool throw_exception_,
std::optional<size_t> exact_limit_, std::string exception_message_ = {});
LimitReadBuffer(std::unique_ptr<ReadBuffer> in_, UInt64 limit_, bool throw_exception_, std::optional<size_t> exact_limit_,
2023-02-22 01:34:03 +00:00
std::string exception_message_ = {});
~LimitReadBuffer() override;
2017-08-14 04:30:37 +00:00
private:
ReadBuffer * in;
bool owns_in;
2019-02-10 15:17:45 +00:00
UInt64 limit;
bool throw_exception;
2023-02-22 16:54:35 +00:00
std::optional<size_t> exact_limit;
std::string exception_message;
2017-08-14 03:38:32 +00:00
2023-02-22 16:54:35 +00:00
LimitReadBuffer(ReadBuffer * in_, bool owns, UInt64 limit_, bool throw_exception_, std::optional<size_t> exact_limit_, std::string exception_message_);
2017-08-14 03:38:32 +00:00
bool nextImpl() override;
2017-08-14 04:30:37 +00:00
};
2012-02-27 06:28:20 +00:00
}