return static_cast<unsigned char>(c);
}
+void Base::set_eof()
+{
+ if(!eof_flag)
+ {
+ eof_flag = true;
+ signal_end_of_file.emit();
+ }
+}
+
} // namespace IO
} // namespace Msp
to end-of-file or non-blocking operation. */
virtual int get();
+protected:
+ void set_eof();
+
+public:
/** Returns the end-of-file flag. */
bool eof() const { return eof_flag; }
};
unsigned ret = sys_read(handle, buf, len);
if(ret==0)
- eof_flag = true;
+ set_eof();
return ret;
}
unsigned ret = sys_read(handle, buf, size);
if(ret==0)
- {
- eof_flag = true;
- signal_end_of_file.emit();
- }
+ set_eof();
return ret;
}
{
if(pos==end)
{
- eof_flag = true;
+ set_eof();
return 0;
}
{
if(pos==end)
{
- eof_flag = true;
+ set_eof();
return -1;
}
return 0;
unsigned ret = reader.read(buf, size);
-
if(ret==0)
- {
- eof_flag = true;
- signal_end_of_file.emit();
- }
+ set_eof();
return ret;
}
if(size==0)
return 0;
- return reader.read(buf, size);
+ unsigned ret = reader.read(buf, size);
+ if(ret==0)
+ set_eof();
+
+ return ret;
}
} // namespace IO