X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput.cpp;fp=source%2Finput.cpp;h=5b2d63b7ba8becdc20232a8933b815b3c5d5f288;hb=5453824394771ca21de32088a2842486b63e6f6d;hp=0000000000000000000000000000000000000000;hpb=7876adf8729437f1c917642c5dd5faf6f2e1fb31;p=libs%2Fdatafile.git diff --git a/source/input.cpp b/source/input.cpp new file mode 100644 index 0000000..5b2d63b --- /dev/null +++ b/source/input.cpp @@ -0,0 +1,37 @@ +/* +This file is part of libmspparser +Copyright © 2006 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ +#include "input.h" + +namespace Msp { +namespace Parser { + +Input::Input(std::istream &i): + in(i), + line(1), + next(-1) +{ } + +int Input::get() +{ + int c=next; + next=-1; + if(c<0) c=in.get(); + + if(c=='\n') + ++line; + + return c; +} + +int Input::peek() +{ + if(next<0) + next=in.get(); + return next; +} + +} // namespace Parser +} // namespace Msp