OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
src
src
Classic
Parser
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
24
TerminalStream::TerminalStream
(
25
const
char
[]
26
):
AbsFileStream
(
"standard input"
) {
27
}
28
29
30
TerminalStream::~TerminalStream
() {
31
}
32
33
34
bool
TerminalStream::fillLine
() {
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
}
TerminalStream.h
AbsFileStream
A stream of input tokens.
Definition:
AbsFileStream.h:31
AbsFileStream::line
std::string line
Definition:
AbsFileStream.h:63
AbsFileStream::curr_char
int curr_char
Definition:
AbsFileStream.h:64
TerminalStream::~TerminalStream
virtual ~TerminalStream()
Definition:
TerminalStream.cpp:30
TerminalStream::TerminalStream
TerminalStream(const char program[])
Constructor.
Definition:
TerminalStream.cpp:24
TerminalStream::fillLine
virtual bool fillLine()
Read next input line.
Definition:
TerminalStream.cpp:34
TokenStream::curr_line
int curr_line
Definition:
TokenStream.h:62
Generated on Wed Aug 25 2021 16:41:03 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.1