OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
TerminalStream.cpp
Go to the documentation of this file.
1 //
2 // Class TerminalStream
3 // A stream of input tokens.
4 // The source of tokens is the terminal.
5 //
6 // Copyright (c) 2012-2019, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
19 #include "Parser/TerminalStream.h"
20 
21 #include <iomanip>
22 #include <iostream>
23 
25  const char[]
26  ): AbsFileStream("standard input") {
27 }
28 
29 
31 }
32 
33 
35  if(std::cin.eof()) {
36  // We must test for end of file, even on terminal, as it may be rerouted.
37  return false;
38  } else {
39  std::cerr << "==>";
40  std::getline(std::cin, line, '\n');
41  line += "\n";
42  curr_line++;
43  std::cerr.width(5);
44  std::cerr << curr_line << " " << line;
45  curr_char = 0;
46  return true;
47  }
48 }
A stream of input tokens.
Definition: AbsFileStream.h:31
std::string line
Definition: AbsFileStream.h:63
virtual ~TerminalStream()
TerminalStream(const char program[])
Constructor.
virtual bool fillLine()
Read next input line.