]> git.tdb.fi Git - libs/datafile.git/blob - source/input.cpp
e03a92126944703234a8d6fa330c4eba66cacb5e
[libs/datafile.git] / source / input.cpp
1 /* $Id$
2
3 This file is part of libmspdatafile
4 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7 #include "input.h"
8
9 namespace Msp {
10 namespace DataFile {
11
12 Input::Input(IO::Base &i):
13         in(i),
14         line(1),
15         next(-1)
16 { }
17
18 int Input::get()
19 {
20         int c=next;
21         next=-1;
22         if(c<0) c=in.get();
23         
24         if(c=='\n')
25                 ++line;
26
27         return c;
28 }
29
30 int Input::peek()
31 {
32         if(next<0)
33                 next=in.get();
34         return next;
35 }
36
37 } // namespace DataFile
38 } // namespace Msp