Fixed block size through filtered streams.

This commit is contained in:
Vincent Richard 2009-04-09 18:15:50 +00:00
parent 50326917bf
commit d0bc8b3a95
4 changed files with 27 additions and 6 deletions

View File

@ -30,6 +30,22 @@ namespace vmime {
namespace utility { 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::dotFilteredInputStream(inputStream& is) dotFilteredInputStream::dotFilteredInputStream(inputStream& is)

View File

@ -38,7 +38,7 @@ namespace utility {
// stream // stream
stream::size_type stream::getBlockSize() const stream::size_type stream::getBlockSize()
{ {
return 32768; // 32 KB 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 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 return 16384; // 16 KB
} }

View File

@ -41,6 +41,8 @@ class filteredInputStream : public inputStream
{ {
public: public:
virtual size_type getBlockSize();
/** Return a reference to the stream being filtered. /** Return a reference to the stream being filtered.
* *
* @return stream being filtered * @return stream being filtered
@ -56,6 +58,8 @@ class filteredOutputStream : public outputStream
{ {
public: public:
virtual size_type getBlockSize();
/** Return a reference to the stream being filtered. /** Return a reference to the stream being filtered.
* *
* @return destination stream for filtered data * @return destination stream for filtered data

View File

@ -77,7 +77,7 @@ public:
* *
* @return block size, in bytes * @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 write(const value_type* const data, const size_type count);
void flush(); void flush();
size_type getBlockSize(){return 8192;}
private: private:
string& m_buffer; string& m_buffer;
@ -402,7 +403,7 @@ public:
void write(const value_type* const data, const size_type count); void write(const value_type* const data, const size_type count);
void flush(); void flush();
size_type getBlockSize() const; size_type getBlockSize();
private: private:
@ -426,7 +427,7 @@ public:
size_type read(value_type* const data, const size_type count); size_type read(value_type* const data, const size_type count);
size_type skip(const size_type count); size_type skip(const size_type count);
size_type getBlockSize() const; size_type getBlockSize();
private: private: