]> git.tdb.fi Git - libs/datafile.git/blob - source/input.cpp
Use default member initializers for constant initial values
[libs/datafile.git] / source / input.cpp
1 #include <msp/io/zlibcompressed.h>
2 #include "input.h"
3
4 namespace Msp {
5 namespace DataFile {
6
7 Input::Input(IO::Base &i):
8         in(&i)
9 { }
10
11 Input::~Input()
12 {
13         delete compressed;
14 }
15
16 void Input::set_decompress()
17 {
18         compressed = new IO::ZlibCompressed(*in, IO::M_READ);
19         in = compressed;
20 }
21
22 int Input::get()
23 {
24         int c = next;
25         next = -1;
26         if(c<0)
27                 c = in->get();
28         
29         if(c=='\n')
30                 ++line;
31
32         return c;
33 }
34
35 int Input::peek()
36 {
37         if(next<0)
38                 next = in->get();
39         return next;
40 }
41
42 Input::operator bool() const
43 {
44         return next>=0 || !in->eof();
45 }
46
47 } // namespace DataFile
48 } // namespace Msp