-
Notifications
You must be signed in to change notification settings - Fork 10
/
RemoteConsole.h
81 lines (58 loc) · 1.51 KB
/
RemoteConsole.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef CCONS_REMOTE_CONSOLE_H
#define CCONS_REMOTE_CONSOLE_H
//
// RemoteConsole is an implementation of IConsole which spawns and communicates
// with a second ccons process for handling the user input.
//
// SerializedOutputConsole is used by the ccons process spawned by RemoteConsole
// to send its output in a serialized format.
//
// Part of ccons, the interactive console for the C programming language.
//
// Copyright (c) 2009 Alexei Svitkine. This file is distributed under the
// terms of MIT Open Source License. See file LICENSE for details.
//
#include <stdio.h>
#include <string>
#include <sstream>
#include "Console.h"
namespace ccons {
//
// RemoteConsole
//
class RemoteConsole : public IConsole {
public:
RemoteConsole(const char * command, bool DebugMode);
virtual ~RemoteConsole();
const char * prompt() const;
const char * input() const;
void process(const char *line);
private:
std::string _command;
bool _DebugMode;
FILE *_ostream;
FILE *_istream;
std::string _prompt;
std::string _input;
void cleanup();
void reset();
};
//
// SerializedOutputConsole
//
class SerializedOutputConsole : public IConsole {
public:
explicit SerializedOutputConsole(bool DebugMode);
virtual ~SerializedOutputConsole();
const char * prompt() const;
const char * input() const;
void process(const char *line);
private:
llvm::OwningPtr<IConsole> _console;
std::stringstream _ss_out;
std::stringstream _ss_err;
FILE *_tmp_out;
FILE *_tmp_err;
};
} // namespace ccons
#endif // CCONS_REMOTE_CONSOLE_H