Rewrite BufferedFile as a standalone class
[libs/core.git] / source / io / file.h
index d106561e5f599cc31367be5f3de9140a4d349cbf..d34273477736c21efdd01335e75306b52f7ba990 100644 (file)
@@ -81,7 +81,29 @@ inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n)
 inline File::CreateMode operator~(File::CreateMode m)
 { return File::CreateMode(~static_cast<int>(m)); }
 
-typedef Filtered<File, Buffered> BufferedFile;
+
+class BufferedFile: public Seekable
+{
+private:
+       File file;
+       Buffered buffer;
+       SeekOffset position;
+
+public:
+       BufferedFile(const std::string &, Mode = M_READ, File::CreateMode = File::C_OVERWRITE);
+
+protected:
+       virtual unsigned do_write(const char *, unsigned);
+       virtual unsigned do_read(char *, unsigned);
+public:
+       virtual unsigned put(char);
+
+       virtual bool getline(std::string &);
+       virtual int get();
+
+       virtual SeekOffset seek(SeekOffset, SeekType);
+       virtual SeekOffset tell() const { return position; }
+};
 
 } // namespace IO
 } // namespace Msp