proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
LineBasedFrameDecoder.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <
folly/io/Cursor.h
>
20
#include <
wangle/codec/ByteToMessageDecoder.h
>
21
22
namespace
wangle
{
23
30
class
LineBasedFrameDecoder
:
public
ByteToByteDecoder
{
31
public
:
32
enum class
TerminatorType
{
33
BOTH
,
34
NEWLINE
,
35
CARRIAGENEWLINE
36
};
37
38
explicit
LineBasedFrameDecoder
(
39
uint32_t
maxLength = UINT_MAX,
40
bool
stripDelimiter =
true
,
41
TerminatorType
terminatorType =
TerminatorType::BOTH
);
42
43
bool
decode
(
Context
* ctx,
44
folly::IOBufQueue
& buf,
45
std::unique_ptr<folly::IOBuf>& result,
46
size_t
&)
override
;
47
48
private
:
49
50
int64_t
findEndOfLine
(
folly::IOBufQueue
& buf);
51
52
void
fail
(
Context
* ctx,
std::string
len);
53
54
uint32_t
maxLength_
;
55
bool
stripDelimiter_
;
56
57
bool
discarding_
{
false
};
58
uint32_t
discardedBytes_
{0};
59
60
TerminatorType
terminatorType_
;
61
};
62
63
}
// namespace wangle
wangle::LineBasedFrameDecoder::stripDelimiter_
bool stripDelimiter_
Definition:
LineBasedFrameDecoder.h:55
wangle::LineBasedFrameDecoder::TerminatorType::CARRIAGENEWLINE
wangle::LineBasedFrameDecoder::TerminatorType::NEWLINE
wangle::LineBasedFrameDecoder::LineBasedFrameDecoder
LineBasedFrameDecoder(uint32_t maxLength=UINT_MAX, bool stripDelimiter=true, TerminatorType terminatorType=TerminatorType::BOTH)
Definition:
LineBasedFrameDecoder.cpp:25
Cursor.h
wangle
Definition:
Acceptor.cpp:49
wangle::LineBasedFrameDecoder::fail
void fail(Context *ctx, std::string len)
Definition:
LineBasedFrameDecoder.cpp:87
wangle::ByteToMessageDecoder::Context
InboundHandler< folly::IOBufQueue &, M >::Context Context
Definition:
ByteToMessageDecoder.h:46
wangle::ByteToMessageDecoder
Definition:
ByteToMessageDecoder.h:44
folly::IOBufQueue
Definition:
IOBufQueue.h:35
wangle::LineBasedFrameDecoder::discarding_
bool discarding_
Definition:
LineBasedFrameDecoder.h:57
ByteToMessageDecoder.h
wangle::LineBasedFrameDecoder::findEndOfLine
int64_t findEndOfLine(folly::IOBufQueue &buf)
Definition:
LineBasedFrameDecoder.cpp:94
wangle::LineBasedFrameDecoder::TerminatorType::BOTH
string
const char * string
Definition:
Conv.cpp:212
wangle::LineBasedFrameDecoder
Definition:
LineBasedFrameDecoder.h:30
wangle::LineBasedFrameDecoder::decode
bool decode(Context *ctx, folly::IOBufQueue &buf, std::unique_ptr< folly::IOBuf > &result, size_t &) override
Definition:
LineBasedFrameDecoder.cpp:32
uint32_t
uint32_t
Definition:
ConstexprMathBenchmark.cpp:186
wangle::LineBasedFrameDecoder::discardedBytes_
uint32_t discardedBytes_
Definition:
LineBasedFrameDecoder.h:58
wangle::LineBasedFrameDecoder::terminatorType_
TerminatorType terminatorType_
Definition:
LineBasedFrameDecoder.h:60
int64_t
int64_t
Definition:
ConstexprMathBenchmark.cpp:188
wangle::LineBasedFrameDecoder::maxLength_
uint32_t maxLength_
Definition:
LineBasedFrameDecoder.h:54
wangle::LineBasedFrameDecoder::TerminatorType
TerminatorType
Definition:
LineBasedFrameDecoder.h:32
proxygen
wangle
wangle
codec
LineBasedFrameDecoder.h
Generated by
1.8.11