Debian Codegraph @

yo/concrete/examples/monitor/processinput.cc

raw
1 #include "monitor.ih"
2
3 //INPUT
4 void Monitor::processInput()
5 {
6 string line;
7 int value;
8 Commands cmd = next(&value, &line);
9 (this->*s_handler[cmd])(value, line);
10 }
11 //=
12 //NEXT
13 Monitor::Commands Monitor::next(int *value, string *line)
14 {
15 if (!getline(cin, *line))
16 exiting(1, "Monitor::next(): reading cin failed");
17
18 if (*line == "start")
19 return START;
20
21 if (*line == "exit" || *line == "quit")
22 {
23 *value = 0;
24 return EXIT;
25 }
26
27 if (line->find("stop") == 0)
28 {
29 istringstream istr(line->substr(4));
30 istr >> *value;
31 return !istr ? UNKNOWN : STOP;
32 }
33
34 istringstream istr(line->c_str());
35 istr >> *value;
36 if (istr)
37 {
38 getline(istr, *line);
39 return TEXT;
40 }
41
42 return UNKNOWN;
43 }
44 //=