VMime
streamContentHandler Class Reference
Inheritance diagram for streamContentHandler:
Collaboration diagram for streamContentHandler:

Public Member Functions

 streamContentHandler ()
 
 streamContentHandler (shared_ptr< utility::inputStream > is, const size_t length, const vmime::encoding &enc=NO_ENCODING)
 
 ~streamContentHandler ()
 
 streamContentHandler (const streamContentHandler &cts)
 
streamContentHandleroperator= (const streamContentHandler &cts)
 
shared_ptr< contentHandlerclone () const
 
void setData (shared_ptr< utility::inputStream > is, const size_t length, const vmime::encoding &enc=NO_ENCODING)
 
void generate (utility::outputStream &os, const vmime::encoding &enc, const size_t maxLineLength=lineLengthLimits::infinite) const
 
void extract (utility::outputStream &os, utility::progressListener *progress=NULL) const
 
void extractRaw (utility::outputStream &os, utility::progressListener *progress=NULL) const
 
size_t getLength () const
 
bool isEncoded () const
 
const vmime::encodinggetEncoding () const
 
bool isEmpty () const
 
bool isBuffered () const
 
void setContentTypeHint (const mediaType &type)
 
const mediaType getContentTypeHint () const
 
- Public Member Functions inherited from contentHandler
virtual ~contentHandler ()
 

Additional Inherited Members

- Static Public Attributes inherited from contentHandler
static const vmime::encoding NO_ENCODING
 
- Protected Member Functions inherited from object
 object ()
 
 object (const object &)
 
objectoperator= (const object &)
 
virtual ~object ()
 

Detailed Description

A content handler which obtains its data from a stream.

Constructor & Destructor Documentation

Creates a new empty content handler.

No data can be extracted until an input stream is set using setData() function.

Returns
a reference to a new content handler
streamContentHandler ( shared_ptr< utility::inputStream is,
const size_t  length,
const vmime::encoding enc = NO_ENCODING 
)

Creates a new content handler using an input stream.

Parameters
isinput stream from which data will be obtained
lengthexpected stream length. May be zero, but it is highly recommended to set this parameter to take part of some optimizations and features (eg. SMTP CHUNKING/SIZE extension).
encset to anything other than NO_ENCODING if the data obtained from the stream is already encoded with the specified encoding
Returns
a reference to a new content handler

References streamContentHandler::setData().

Member Function Documentation

shared_ptr< contentHandler > clone ( ) const
virtual

Return a copy of this object.

Returns
copy of this object

Implements contentHandler.

void extract ( utility::outputStream os,
utility::progressListener progress = NULL 
) const
virtual

Extract the contents into the specified stream.

If needed, data will be decoded before being written into the stream.

Exceptions
exceptions::no_encoder_availableif the encoding is not supported
Parameters
osoutput stream
progressprogress listener, or NULL if you do not want to receive progress notifications

Implements contentHandler.

References vmime::utility::bufferedStreamCopy(), encoding::getEncoder(), streamContentHandler::getLength(), and streamContentHandler::isEncoded().

void extractRaw ( utility::outputStream os,
utility::progressListener progress = NULL 
) const
virtual

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.

Parameters
osoutput stream
progressprogress listener, or NULL if you do not want to receive progress notifications

Implements contentHandler.

References vmime::utility::bufferedStreamCopy(), and streamContentHandler::getLength().

void generate ( utility::outputStream os,
const vmime::encoding enc,
const size_t  maxLineLength = lineLengthLimits::infinite 
) const
virtual

Output the contents into the specified stream.

Data will be encoded before being written into the stream. This is used internally by the body object to generate the message, you may not need to use this (see contentHandler::extract() if you want to get the contents).

Parameters
osoutput stream
encencoding for output
maxLineLengthmaximum line length for output

Implements contentHandler.

References vmime::utility::bufferedStreamCopy(), encoding::getEncoder(), mediaType::getType(), streamContentHandler::isEncoded(), and vmime::mediaTypes::TEXT.

const mediaType getContentTypeHint ( ) const
virtual

Returns a hint about the kind of data managed by this object.

Returns
type content media type

Implements contentHandler.

const vmime::encoding & getEncoding ( ) const
virtual

Returns the encoding used for data (or "binary" if not encoded).

Returns
encoding used for data

Implements contentHandler.

size_t getLength ( ) const
virtual

Returns the actual length of data.

WARNING: this can return 0 if no length was specified when setting data of this object, or if the length is not known).

Returns
length of data

Implements contentHandler.

Referenced by streamContentHandler::extract(), and streamContentHandler::extractRaw().

bool isBuffered ( ) const
virtual

Indicates whether the extract() method can be called multiple times.

Returns
true if the data can be extracted multiple times, or false if not (ie. streamed data from socket)

Implements contentHandler.

bool isEmpty ( ) const
virtual

Returns 'true' if there is no data set.

Returns
true if no data is managed by this object, false otherwise

Implements contentHandler.

bool isEncoded ( ) const
virtual

Returns 'true' if data managed by this object is encoded.

Returns
true if data is encoded, false otherwise

Implements contentHandler.

References contentHandler::NO_ENCODING.

Referenced by streamContentHandler::extract(), and streamContentHandler::generate().

streamContentHandler & operator= ( const streamContentHandler cts)
void setContentTypeHint ( const mediaType type)
virtual

Gives a hint about the kind of data managed by this object.

Parameters
typecontent media type

Implements contentHandler.

void setData ( shared_ptr< utility::inputStream is,
const size_t  length,
const vmime::encoding enc = NO_ENCODING 
)

Sets the data managed by this content handler.

Parameters
isinput stream from which data will be obtained
lengthexpected stream length. May be zero, but it is highly recommended to set this parameter to take part of some optimizations and features (eg. SMTP CHUNKING/SIZE extension).
encset to anything other than NO_ENCODING if the data obtained from the stream is already encoded with the specified encoding

Referenced by fileContentHandler::setData(), and streamContentHandler::streamContentHandler().


The documentation for this class was generated from the following files: