]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/input.cpp
Remove the loaded flag from PackSource files
[libs/datafile.git] / source / input.cpp
index c421f01b977c36797d95c41d60f3787f4bdf3ac4..4a44dea05228ae14d1d91e698ebe4eecf98cb662 100644 (file)
@@ -1,25 +1,33 @@
-/* $Id$
-
-This file is part of libmspdatafile
-Copyright © 2006  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
+#include <msp/io/zlibcompressed.h>
 #include "input.h"
 
 namespace Msp {
 namespace DataFile {
 
-Input::Input(std::istream &i):
-       in(i),
+Input::Input(IO::Base &i):
+       in(&i),
+       compressed(0),
        line(1),
        next(-1)
 { }
 
+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,9 +38,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