| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#pragma once |
|
2
|
|
|
|
|
|
|
#include |
|
3
|
|
|
|
|
|
|
#include |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
namespace panda { namespace protocol { namespace websocket { |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
// Incremental UTF8 validator. Based on boost::beast |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
struct Utf8Checker { |
|
10
|
83
|
|
|
|
|
|
void reset () { |
|
11
|
83
|
|
|
|
|
|
need_ = 0; |
|
12
|
83
|
|
|
|
|
|
p_ = cp_; |
|
13
|
83
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
|
bool finish () { |
|
16
|
5
|
|
|
|
|
|
auto const success = need_ == 0; |
|
17
|
5
|
|
|
|
|
|
reset(); |
|
18
|
5
|
|
|
|
|
|
return success; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
bool write (const string&); |
|
22
|
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
|
bool write (const std::vector& v) { |
|
24
|
21
|
100
|
|
|
|
|
for (const auto& s : v) if (!write(s)) return false; |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
|
return true; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
private: |
|
29
|
|
|
|
|
|
|
std::uint8_t cp_[4]; // a temp buffer for the code point |
|
30
|
|
|
|
|
|
|
size_t need_ = 0; // chars we need to finish the code point |
|
31
|
|
|
|
|
|
|
std::uint8_t* p_ = cp_; // current position in temp buffer |
|
32
|
|
|
|
|
|
|
}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
}}} |