X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput.cpp;h=d74c8efde0a943fb8cdb11f8f4f3281f88d21d9a;hb=cbd0ddd6ee033e46646bfb85d19232c816ea1eda;hp=c421f01b977c36797d95c41d60f3787f4bdf3ac4;hpb=8ff59df1f2e603557eceacbc81a8dc44de051dae;p=libs%2Fdatafile.git diff --git a/source/input.cpp b/source/input.cpp index c421f01..d74c8ef 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -9,7 +9,7 @@ Distributed under the LGPL namespace Msp { namespace DataFile { -Input::Input(std::istream &i): +Input::Input(IO::Base &i): in(i), line(1), next(-1) @@ -17,9 +17,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; @@ -30,9 +30,14 @@ int Input::get() int Input::peek() { if(next<0) - next=in.get(); + next = in.get(); return next; } +Input::operator bool() const +{ + return next>=0 || !in.eof(); +} + } // namespace DataFile } // namespace Msp