From d0bc8b3a951334471a81e099f15696c5353aac47 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 9 Apr 2009 18:15:50 +0000 Subject: [PATCH] Fixed block size through filtered streams. --- src/utility/filteredStream.cpp | 16 ++++++++++++++++ src/utility/stream.cpp | 6 +++--- vmime/utility/filteredStream.hpp | 4 ++++ vmime/utility/stream.hpp | 7 ++++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/utility/filteredStream.cpp b/src/utility/filteredStream.cpp index eda0c64c..5db01047 100644 --- a/src/utility/filteredStream.cpp +++ b/src/utility/filteredStream.cpp @@ -30,6 +30,22 @@ namespace vmime { namespace utility { +// filteredInputStream + +stream::size_type filteredInputStream::getBlockSize() +{ + return std::min(inputStream::getBlockSize(), getPreviousInputStream().getBlockSize()); +} + + +// filteredOutputStream + +stream::size_type filteredOutputStream::getBlockSize() +{ + return std::min(outputStream::getBlockSize(), getNextOutputStream().getBlockSize()); +} + + // dotFilteredInputStream dotFilteredInputStream::dotFilteredInputStream(inputStream& is) diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp index bb5300ef..8fbf337b 100644 --- a/src/utility/stream.cpp +++ b/src/utility/stream.cpp @@ -38,7 +38,7 @@ namespace utility { // stream -stream::size_type stream::getBlockSize() const +stream::size_type stream::getBlockSize() { return 32768; // 32 KB } @@ -468,7 +468,7 @@ void outputStreamSocketAdapter::flush() } -stream::size_type outputStreamSocketAdapter::getBlockSize() const +stream::size_type outputStreamSocketAdapter::getBlockSize() { return 16384; // 16 KB } @@ -511,7 +511,7 @@ stream::size_type inputStreamSocketAdapter::skip } -stream::size_type inputStreamSocketAdapter::getBlockSize() const +stream::size_type inputStreamSocketAdapter::getBlockSize() { return 16384; // 16 KB } diff --git a/vmime/utility/filteredStream.hpp b/vmime/utility/filteredStream.hpp index 9f64ba95..1e03697a 100644 --- a/vmime/utility/filteredStream.hpp +++ b/vmime/utility/filteredStream.hpp @@ -41,6 +41,8 @@ class filteredInputStream : public inputStream { public: + virtual size_type getBlockSize(); + /** Return a reference to the stream being filtered. * * @return stream being filtered @@ -56,6 +58,8 @@ class filteredOutputStream : public outputStream { public: + virtual size_type getBlockSize(); + /** Return a reference to the stream being filtered. * * @return destination stream for filtered data diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp index a9c079ba..5f7bfa2c 100644 --- a/vmime/utility/stream.hpp +++ b/vmime/utility/stream.hpp @@ -77,7 +77,7 @@ public: * * @return block size, in bytes */ - virtual size_type getBlockSize() const; + virtual size_type getBlockSize(); }; @@ -239,6 +239,7 @@ public: void write(const value_type* const data, const size_type count); void flush(); +size_type getBlockSize(){return 8192;} private: string& m_buffer; @@ -402,7 +403,7 @@ public: void write(const value_type* const data, const size_type count); void flush(); - size_type getBlockSize() const; + size_type getBlockSize(); private: @@ -426,7 +427,7 @@ public: size_type read(value_type* const data, const size_type count); size_type skip(const size_type count); - size_type getBlockSize() const; + size_type getBlockSize(); private: