-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputbuf.cc
More file actions
41 lines (35 loc) · 698 Bytes
/
Copy pathinputbuf.cc
File metadata and controls
41 lines (35 loc) · 698 Bytes
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
#include <iostream>
#include <istream>
#include <vector>
#include <string>
#include <cstdio>
#include "inputbuf.h"
using namespace std;
bool InputBuffer::EndOfInput()
{
if (!input_buffer.empty())
return false;
else
return cin.eof();
}
char InputBuffer::UngetChar(char c)
{
if (c != EOF)
input_buffer.push_back(c);;
return c;
}
void InputBuffer::GetChar(char& c)
{
if (!input_buffer.empty()) {
c = input_buffer.back();
input_buffer.pop_back();
} else {
cin.get(c);
}
}
string InputBuffer::UngetString(string s)
{
for (int i = 0; i < s.size(); i++)
input_buffer.push_back(s[s.size()-i-1]);
return s;
}