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