]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/input.h
Move the definition of Input's operator bool to the header
[libs/datafile.git] / source / input.h
index a9c96f48abce9cdf9e533e640f3913c8849e0d7f..7f4dd7b988a3b988911797cde037ab733658e84e 100644 (file)
@@ -1,18 +1,19 @@
 #ifndef MSP_DATAFILE_INPUT_H_
 #define MSP_DATAFILE_INPUT_H_
 
+#include <msp/core/noncopyable.h>
 #include <msp/io/base.h>
 
 namespace Msp {
 namespace DataFile {
 
-class Input
+class Input: private NonCopyable
 {   
 private:
-       IO::Base *in;
-       IO::Base *compressed;
-       unsigned line;
-       int next;
+       IO::Base *in = nullptr;
+       IO::Base *compressed = nullptr;
+       unsigned line = 1;
+       int next = -1;
 
 public:
        Input(IO::Base &); 
@@ -22,7 +23,7 @@ public:
        int get();
        int peek();
        unsigned get_line_number() const { return line; }
-       operator bool() const;
+       explicit operator bool() const { return (next>=0 || !in->eof()); }
 };  
 
 } // namespace DataFile