}
}
-const Handle &Base::get_handle(Mode)
-{
- throw logic_error("Base::get_handle");
-}
-
Base::Synchronize::Synchronize(Base &i):
io(i)
was done.
Blocking is enabled by default. */
- virtual void set_block(bool) { }
+ virtual void set_block(bool) = 0;
/** Returns the current mode flags. */
Mode get_mode() const { return mode; }
/** Returns the system-level handle for the object. Used by Console to
perform redirections. */
- virtual const Handle &get_handle(Mode);
+ virtual const Handle &get_handle(Mode) = 0;
};
} // namespace IO
delete[] buf;
}
+void Buffered::set_block(bool)
+{
+ throw logic_error("Buffered::set_block");
+}
+
void Buffered::flush()
{
if(cur_op==M_WRITE)
return static_cast<unsigned char>(c);
}
+const Handle &Buffered::get_handle(Mode)
+{
+ throw logic_error("Buffered::get_handle");
+}
+
void Buffered::set_op(Mode op)
{
if(op!=cur_op)
Buffered(Base &, unsigned =8192);
~Buffered();
+ virtual void set_block(bool);
+
void flush();
protected:
bool getline(std::string &);
int get();
+ virtual const Handle &get_handle(Mode);
+
private:
void set_op(Mode);
public:
file.signal_end_of_file.connect(sigc::mem_fun(this, &BufferedFile::set_eof));
}
+void BufferedFile::set_block(bool b)
+{
+ file.set_block(b);
+}
+
unsigned BufferedFile::do_write(const char *buf, unsigned size)
{
unsigned ret = buffer.write(buf, size);
return ret;
}
+const Handle &BufferedFile::get_handle(Mode)
+{
+ throw logic_error("BufferedFile::get_handle");
+}
+
SeekOffset BufferedFile::seek(SeekOffset offset, SeekType type)
{
if(type==S_CUR)
public:
virtual ~File();
- void set_block(bool);
+ virtual void set_block(bool);
protected:
virtual unsigned do_write(const char *, unsigned);
public:
BufferedFile(const std::string &, Mode = M_READ, File::CreateMode = File::C_OVERWRITE);
+ virtual void set_block(bool);
+
protected:
virtual unsigned do_write(const char *, unsigned);
virtual unsigned do_read(char *, unsigned);
virtual bool getline(std::string &);
virtual int get();
+ virtual const Handle &get_handle(Mode);
+
virtual SeekOffset seek(SeekOffset, SeekType);
virtual SeekOffset tell() const { return position; }
};
mode = m;
}
+void Memory::set_block(bool)
+{
+ throw logic_error("Memory::set_block");
+}
+
unsigned Memory::do_write(const char *buf, unsigned size)
{
check_access(M_WRITE);
return static_cast<unsigned char>(*pos++);
}
+const Handle &Memory::get_handle(Mode)
+{
+ throw logic_error("Memory::get_handle");
+}
+
SeekOffset Memory::seek(SeekOffset off, SeekType type)
{
char *new_pos;
private:
void init(char *, char *, Mode);
+public:
+ virtual void set_block(bool);
+
+private:
virtual unsigned do_write(const char *, unsigned);
virtual unsigned do_read(char *, unsigned);
public:
virtual bool getline(std::string &);
virtual int get();
+ virtual const Handle &get_handle(Mode);
+
virtual SeekOffset seek(SeekOffset, SeekType);
virtual SeekOffset tell() const { return pos-begin; }
};
~Pipe();
void set_mode(Mode);
- void set_block(bool);
+ virtual void set_block(bool);
protected:
virtual unsigned do_write(const char *, unsigned);
below.signal_flush_required.connect(sigc::mem_fun(this, &Slice::flush));
}
+void Slice::set_block(bool)
+{
+ throw logic_error("Slice::set_block");
+}
+
void Slice::flush()
{
sync_position = true;
return c;
}
+const Handle &Slice::get_handle(Mode)
+{
+ throw logic_error("Slice::get_handle");
+}
+
SeekOffset Slice::seek(SeekOffset off, SeekType type)
{
Base::Synchronize sync(below);
public:
Slice(Seekable &, SeekOffset, SeekOffset);
+ virtual void set_block(bool);
+
private:
void flush();
virtual unsigned put(char);
virtual int get();
+ virtual const Handle &get_handle(Mode);
+
virtual SeekOffset seek(SeekOffset, SeekType);
virtual SeekOffset tell() const { return position; }
};
delete priv;
}
+void ZlibCompressed::set_block(bool)
+{
+ throw logic_error("ZlibCompressed::set_block");
+}
+
void ZlibCompressed::flush()
{
#ifdef WITH_ZLIB
return processed;
}
+const Handle &ZlibCompressed::get_handle(Mode)
+{
+ throw logic_error("ZlibCompressed::get_handle");
+}
+
} // namespace IO
} // namespace Msp
public:
virtual ~ZlibCompressed();
+ virtual void set_block(bool);
+
void flush();
protected:
public:
virtual unsigned do_read(char *, unsigned);
+
+ virtual const Handle &get_handle(Mode);
};
} // namespace IO