-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrxprotocol.hpp
43 lines (34 loc) · 925 Bytes
/
rxprotocol.hpp
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
#pragma once
#include <string>
#include <unordered_map>
#include <iostream>
#include "config.hpp"
namespace remexec {
class RXProtocol {
private:
class OutPackerBuf : public std::streambuf {
private:
int fd;
char_type *buf;
std::size_t bufsize;
std::ostream *out;
protected:
virtual int overflow(int ch) override;
virtual int sync() override;
public:
OutPackerBuf(int fd, std::size_t bufsize, std::ostream &out);
virtual ~OutPackerBuf();
};
std::istream *in;
std::ostream *out;
Config &config;
void response(std::string status, std::string info = "", std::unordered_map<std::string, std::string> params = {});
void error(int code, std::string info);
public:
RXProtocol(Config &conf);
~RXProtocol();
void process(std::istream &in, std::ostream &out);
static std::string encodeParameterValue(const std::string &val);
static std::string decodeParameterValue(const std::string &val);
};
}