X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput.cpp;h=cc82227281563a195fa3a88c5d6e78ef4c44ffc1;hb=19179a622c1de88de5ed7047643eec79f285bf2a;hp=5b2d63b7ba8becdc20232a8933b815b3c5d5f288;hpb=5453824394771ca21de32088a2842486b63e6f6d;p=libs%2Fdatafile.git diff --git a/source/input.cpp b/source/input.cpp index 5b2d63b..cc82227 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -1,14 +1,9 @@ -/* -This file is part of libmspparser -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ #include "input.h" namespace Msp { -namespace Parser { +namespace DataFile { -Input::Input(std::istream &i): +Input::Input(IO::Base &i): in(i), line(1), next(-1) @@ -16,9 +11,9 @@ Input::Input(std::istream &i): int Input::get() { - int c=next; - next=-1; - if(c<0) c=in.get(); + int c = next; + next = -1; + if(c<0) c = in.get(); if(c=='\n') ++line; @@ -29,9 +24,14 @@ int Input::get() int Input::peek() { if(next<0) - next=in.get(); + next = in.get(); return next; } -} // namespace Parser +Input::operator bool() const +{ + return next>=0 || !in.eof(); +} + +} // namespace DataFile } // namespace Msp