]> git.tdb.fi Git - libs/datafile.git/blob - source/input.cpp
cc82227281563a195fa3a88c5d6e78ef4c44ffc1
[libs/datafile.git] / source / input.cpp
1 #include "input.h"
2
3 namespace Msp {
4 namespace DataFile {
5
6 Input::Input(IO::Base &i):
7         in(i),
8         line(1),
9         next(-1)
10 { }
11
12 int Input::get()
13 {
14         int c = next;
15         next = -1;
16         if(c<0) c = in.get();
17         
18         if(c=='\n')
19                 ++line;
20
21         return c;
22 }
23
24 int Input::peek()
25 {
26         if(next<0)
27                 next = in.get();
28         return next;
29 }
30
31 Input::operator bool() const
32 {
33         return next>=0 || !in.eof();
34 }
35
36 } // namespace DataFile
37 } // namespace Msp