28 : maxLength_(maxLength)
29 , stripDelimiter_(stripDelimiter)
30 , terminatorType_(terminatorType) {}
34 std::unique_ptr<IOBuf>& result,
42 auto delimLength = c.read<
char>() ==
'\r' ? 2 : 1;
44 buf.
split(eol + delimLength);
45 fail(ctx, folly::to<std::string>(eol));
49 std::unique_ptr<folly::IOBuf> frame;
52 frame = buf.
split(eol);
55 frame = buf.
split(eol + delimLength);
66 fail(ctx,
"over " + folly::to<std::string>(len));
74 auto delimLength = c.read<
char>() ==
'\r' ? 2 : 1;
88 ctx->fireReadException(
89 folly::make_exception_wrapper<std::runtime_error>(
90 "frame length" + len +
91 " exeeds max " + folly::to<std::string>(
maxLength_)));
97 auto b =
c.read<
char>();
101 b ==
'\r' && !
c.isAtEnd() &&
c.read<
char>() ==
'\n') {
std::unique_ptr< folly::IOBuf > split(size_t n)
const folly::IOBuf * front() const
size_t chainLength() const
constexpr detail::Map< Move > move
std::unique_ptr< folly::IOBuf > move()
LineBasedFrameDecoder(uint32_t maxLength=UINT_MAX, bool stripDelimiter=true, TerminatorType terminatorType=TerminatorType::BOTH)
void fail(Context *ctx, std::string len)
InboundHandler< folly::IOBufQueue &, M >::Context Context
int64_t findEndOfLine(folly::IOBufQueue &buf)
bool decode(Context *ctx, folly::IOBufQueue &buf, std::unique_ptr< folly::IOBuf > &result, size_t &) override
void trimStart(size_t amount)
TerminatorType terminatorType_