diff options
author | vng <viktor.govako@gmail.com> | 2011-11-25 00:29:32 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:28:44 +0300 |
commit | f28bb0b4908487f35ab54f038ec164a13c3cc027 (patch) | |
tree | 0c62c8894298fbcce39e84369ef8d7cb69af1d5a /coding/reader_streambuf.cpp | |
parent | 65530f86918698ec5cc6dbdd408e6295c28f7c1a (diff) |
Forget to commit WriterStreamBuffer.
Diffstat (limited to 'coding/reader_streambuf.cpp')
-rw-r--r-- | coding/reader_streambuf.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/coding/reader_streambuf.cpp b/coding/reader_streambuf.cpp index 3cfaef1fc8..2379ce2c35 100644 --- a/coding/reader_streambuf.cpp +++ b/coding/reader_streambuf.cpp @@ -1,5 +1,6 @@ #include "reader_streambuf.hpp" #include "reader.hpp" +#include "file_writer.hpp" #include "../std/algorithm.hpp" @@ -38,3 +39,33 @@ ReaderStreamBuf::int_type ReaderStreamBuf::underflow() return traits_type::eof(); } } + + +WriterStreamBuf::~WriterStreamBuf() +{ + delete m_writer; +} + +std::streamsize WriterStreamBuf::xsputn(char_type const * s, std::streamsize n) +{ + m_writer->Write(s, n); + return n; +} + +WriterStreamBuf::int_type WriterStreamBuf::overflow(int_type c) +{ + if (!traits_type::eq_int_type(c, traits_type::eof())) + { + char_type const t = traits_type::to_char_type(c); + xsputn(&t, 1); + } + return !traits_type::eof(); +} + +int WriterStreamBuf::sync() +{ + FileWriter * p = dynamic_cast<FileWriter *>(m_writer); + if (p) + p->Flush(); + return 0; +} |