X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fbuffered.cpp;h=77a5f45cef353e2771842f0b197f7cc48d443f35;hp=f53d2fc23fa49e38ede87da0188b40d3cfeadb50;hb=20c897ece781e18ba54c41fd68e232ce566a938d;hpb=6e0fd758970bcb5bad5e3f2454b694cc4d7b4b66 diff --git a/source/io/buffered.cpp b/source/io/buffered.cpp index f53d2fc..77a5f45 100644 --- a/source/io/buffered.cpp +++ b/source/io/buffered.cpp @@ -1,6 +1,7 @@ #include +#include #include "buffered.h" -#include "except.h" +#include "handle.h" using namespace std; @@ -31,6 +32,16 @@ Buffered::~Buffered() delete[] buf; } +void Buffered::set_block(bool) +{ + throw logic_error("Buffered::set_block"); +} + +void Buffered::set_inherit(bool) +{ + throw logic_error("Buffered::set_block"); +} + void Buffered::flush() { if(cur_op==M_WRITE) @@ -40,17 +51,17 @@ void Buffered::flush() { unsigned len = below.write(begin, used); - begin=end = buf; + begin = end = buf; if(len(end-begin), size); + len = min(end-begin, size); memcpy(data, begin, len); begin += len; ret += len; @@ -126,7 +137,7 @@ unsigned Buffered::do_read(char *data, unsigned size) } } -unsigned Buffered::put(char c) +size_t Buffered::put(char c) { set_op(M_WRITE); @@ -139,7 +150,7 @@ unsigned Buffered::put(char c) return do_write(&c, 1); } -bool Buffered::getline(std::string &line) +bool Buffered::getline(string &line) { set_op(M_READ); @@ -167,6 +178,11 @@ int Buffered::get() return static_cast(c); } +const Handle &Buffered::get_handle(Mode) +{ + throw logic_error("Buffered::get_handle"); +} + void Buffered::set_op(Mode op) { if(op!=cur_op) @@ -174,15 +190,10 @@ void Buffered::set_op(Mode op) cur_op = op; } -unsigned Buffered::get_current_size() const +size_t Buffered::get_current_size() const { return end-begin; } -Handle Buffered::get_event_handle() -{ - throw Exception("Buffered doesn't support events"); -} - } // namespace IO } // namespace Msp