X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput.cpp;h=4a44dea05228ae14d1d91e698ebe4eecf98cb662;hb=HEAD;hp=f3f8f23f3343fa9352a618c82f8c151f2811573e;hpb=e26f7e98e5d8a5666192a43348b3ca7a35f6b860;p=libs%2Fdatafile.git diff --git a/source/input.cpp b/source/input.cpp index f3f8f23..8aec39e 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -1,25 +1,30 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ +#include #include "input.h" namespace Msp { namespace DataFile { Input::Input(IO::Base &i): - in(i), - line(1), - next(-1) + in(&i) { } +Input::~Input() +{ + delete compressed; +} + +void Input::set_decompress() +{ + compressed = new IO::ZlibCompressed(*in, IO::M_READ); + in = compressed; +} + 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,13 +35,13 @@ 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(); + return next>=0 || !in->eof(); } } // namespace DataFile