Added contentHandler::extractRaw().

This commit is contained in:
Vincent Richard 2005-07-06 20:28:43 +00:00
parent 919a64a803
commit 53f96cdb75
8 changed files with 44 additions and 0 deletions

View File

@ -2,6 +2,11 @@
VERSION 0.7.2cvs
================
2005-07-06 Vincent Richard <vincent@vincent-richard.net>
* *contentHandler.{hpp|cpp}: added extractRaw() method to allow extracting
data without performing any decoding.
2005-06-22 Vincent Richard <vincent@vincent-richard.net>
* Started version 0.7.2.

View File

@ -48,6 +48,12 @@ void emptyContentHandler::extract(utility::outputStream& /* os */) const
}
void emptyContentHandler::extractRaw(utility::outputStream& /* os */) const
{
// Nothing to do.
}
const string::size_type emptyContentHandler::getLength() const
{
return (0);

View File

@ -179,6 +179,20 @@ void streamContentHandler::extract(utility::outputStream& os) const
}
void streamContentHandler::extractRaw(utility::outputStream& os) const
{
if (m_stream == NULL && m_ownedStream.ptr() == NULL)
return;
utility::inputStream& in = const_cast <utility::inputStream&>
(*(m_stream ? m_stream : m_ownedStream.ptr()));
in.reset(); // may not work...
utility::bufferedStreamCopy(in, os);
}
const string::size_type streamContentHandler::getLength() const
{
return (m_length);

View File

@ -165,6 +165,12 @@ void stringContentHandler::extract(utility::outputStream& os) const
}
void stringContentHandler::extractRaw(utility::outputStream& os) const
{
m_string.extract(os);
}
const string::size_type stringContentHandler::getLength() const
{
return (m_string.length());

View File

@ -63,10 +63,20 @@ public:
/** Extract the contents into the specified stream. If needed, data
* will be decoded before being written into the stream.
*
* @throw exceptions::no_encoder_available if the encoding is
* not supported
* @param os output stream
*/
virtual void extract(utility::outputStream& os) const = 0;
/** Extract the contents into the specified stream, without
* decoding it. It may be useful in case the encoding is not
* supported and you want to extract raw data.
*
* @param os output stream
*/
virtual void extractRaw(utility::outputStream& os) const = 0;
/** Returns the actual length of data. WARNING: this can return 0 if no
* length was specified when setting data of this object.
*

View File

@ -39,6 +39,7 @@ public:
void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const;
void extract(utility::outputStream& os) const;
void extractRaw(utility::outputStream& os) const;
const string::size_type getLength() const;

View File

@ -48,6 +48,7 @@ public:
void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const;
void extract(utility::outputStream& os) const;
void extractRaw(utility::outputStream& os) const;
const string::size_type getLength() const;

View File

@ -66,6 +66,7 @@ public:
void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const;
void extract(utility::outputStream& os) const;
void extractRaw(utility::outputStream& os) const;
const string::size_type getLength() const;