-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctrl_stream_writer.h
More file actions
60 lines (44 loc) · 1.7 KB
/
Copy pathctrl_stream_writer.h
File metadata and controls
60 lines (44 loc) · 1.7 KB
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
56
57
58
59
60
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ctrl_stream_writer.h
#ifndef _CTRL_STREAM_WRITER_H
# define _CTRL_STREAM_WRITER_H
# include "ctrl_stream.h"
# include <ostream>
# include <string>
# include <vector>
//=============================================================================
// CtrlStreamWriter - writes control commands to an output stream
//=============================================================================
class CtrlStreamWriter
{
public:
explicit CtrlStreamWriter(std::ostream &out);
/// Send a start request with config name, path, symbol set and log threshold
void writeStart(const wstringi &configName,
const wstringi &configPath,
const Symbols &syms,
LogLevel logLevel);
/// Send a new log threshold
void writeSetLogLevel(LogLevel logLevel);
/// Send a quit request
void writeQuit();
/// Send an ExecUserFunc request to scripter
void writeExecUserFunc(const wstringi &funcName,
const std::vector<FuncArg> &args,
const TriggerInfo &ctx);
private:
std::ostream &m_out;
/// While set, the primitives append here instead of writing to the stream.
/// writeExecUserFunc() uses it to serialize the arguments before the count
/// that describes them is committed to the stream.
std::string *m_buf = nullptr;
// Primitive writers (little-endian, same convention as CmdStreamWriter)
void writeU8(uint8_t v);
void writeU16(uint16_t v);
void writeU32(uint32_t v);
void writeI32(int32_t v);
void writeU64(uint64_t v);
void writeString(const wstringi &s);
void writeFuncArg(const FuncArg &arg);
};
#endif // !_CTRL_STREAM_WRITER_H