]> git.tdb.fi Git - libs/datafile.git/blob - source/input.cpp
f3f8f23f3343fa9352a618c82f8c151f2811573e
[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 Input::operator bool() const
38 {
39         return next>=0 || !in.eof();
40 }
41
42 } // namespace DataFile
43 } // namespace Msp