-/*
-This file is part of libmspparser
-Copyright © 2006 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
+#include <msp/io/zlibcompressed.h>
#include "input.h"
namespace Msp {
-namespace Parser {
+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);
+ 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;
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