X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fbuffered.cpp;fp=source%2Fbuffered.cpp;h=f53d2fc23fa49e38ede87da0188b40d3cfeadb50;hp=e36aef460dd8e163cadb6aec006b235e3fd0f8c9;hb=b97d4e9f86e90254ab9edef7ee62a910f6333c78;hpb=49c1f3c3ffdf318579a809f3f800442c0c76c818 diff --git a/source/buffered.cpp b/source/buffered.cpp index e36aef4..f53d2fc 100644 --- a/source/buffered.cpp +++ b/source/buffered.cpp @@ -19,17 +19,16 @@ Buffered::Buffered(Base &b, unsigned s): below.signal_flush_required.connect(sigc::mem_fun(this, &Buffered::flush)); } -unsigned Buffered::put(char c) +Buffered::~Buffered() { - set_op(M_WRITE); - - if(end(*begin++); - - char c; - if(do_read(&c, 1)==0) - return -1; - return static_cast(c); -} - -Handle Buffered::get_event_handle() -{ - throw Exception("Buffered doesn't support events"); -} - -unsigned Buffered::get_current_size() const -{ - return end-begin; -} - -Buffered::~Buffered() -{ - try - { - flush(); - } - catch(...) - { } - - delete[] buf; -} - -void Buffered::set_op(Mode op) -{ - if(op!=cur_op) - flush(); - cur_op = op; -} - unsigned Buffered::do_write(const char *data, unsigned size) { set_op(M_WRITE); @@ -184,5 +126,63 @@ unsigned Buffered::do_read(char *data, unsigned size) } } +unsigned Buffered::put(char c) +{ + set_op(M_WRITE); + + if(end(*begin++); + + char c; + if(do_read(&c, 1)==0) + return -1; + return static_cast(c); +} + +void Buffered::set_op(Mode op) +{ + if(op!=cur_op) + flush(); + cur_op = op; +} + +unsigned Buffered::get_current_size() const +{ + return end-begin; +} + +Handle Buffered::get_event_handle() +{ + throw Exception("Buffered doesn't support events"); +} + } // namespace IO } // namespace Msp