-
Notifications
You must be signed in to change notification settings - Fork 10
/
LineReader.h
54 lines (35 loc) · 987 Bytes
/
LineReader.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
#ifndef CCONS_LINE_READER_H
#define CCONS_LINE_READER_H
//
// LineReader defines an interface to be implemented by derived classes for
// reading line input from the users.
//
// 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 <string>
namespace ccons {
//
// LineReader interface
//
class LineReader {
public:
virtual ~LineReader() {}
// Reads a line by presenting the specified prompt and pre-pending
// the specified input string.
virtual const char * readLine(const char *prompt, const char *input) = 0;
};
//
// StdInLineReader simply reads lines from stdin.
//
class StdInLineReader : public LineReader {
public:
StdInLineReader();
const char * readLine(const char *prompt, const char *input);
private:
std::string _line;
};
} // namespace ccons
#endif // CCONS_LINE_READER_H