-
Notifications
You must be signed in to change notification settings - Fork 29
/
hessian_utils.h
55 lines (43 loc) · 1.31 KB
/
hessian_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <string>
#include "envoy/buffer/buffer.h"
#include "absl/strings/string_view.h"
#include "hessian2/basic_codec/object_codec.hpp"
#include "hessian2/codec.hpp"
#include "hessian2/object.hpp"
#include "hessian2/reader.hpp"
#include "hessian2/writer.hpp"
namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
namespace MetaProtocolProxy {
namespace Dubbo {
class HessianUtils {
public:
static uint32_t getParametersNumber(const std::string& parameters_type);
};
class BufferWriter : public Hessian2::Writer {
public:
BufferWriter(Envoy::Buffer::Instance& buffer) : buffer_(buffer) {}
// Hessian2::Writer
void rawWrite(const void* data, uint64_t size) override;
void rawWrite(absl::string_view data) override;
private:
Envoy::Buffer::Instance& buffer_;
};
class BufferReader : public Hessian2::Reader {
public:
BufferReader(Envoy::Buffer::Instance& buffer, uint64_t initial_offset = 0) : buffer_(buffer) {
initial_offset_ = initial_offset;
}
// Hessian2::Reader
uint64_t length() const override { return buffer_.length(); }
void rawReadNBytes(void* data, size_t len, size_t peek_offset) override;
private:
Envoy::Buffer::Instance& buffer_;
};
} // namespace Dubbo
} // namespace MetaProtocolProxy
} // namespace NetworkFilters
} // namespace Extensions
} // namespace Envoy