class Poco::Net::PartSource

Overview

This abstract class is used for adding parts or attachments to mail messages, as well as for uploading files as part of a HTML form. Moreā€¦

#include <PartSource.h>

class PartSource
{
public:
    // fields

    static const int UNKNOWN_CONTENT_LENGTH;

    // methods

    virtual
    std::istream&
    stream() = 0;

    virtual
    const std::string&
    filename() const;

    const std::string&
    mediaType() const;

    MessageHeader&
    headers();

    const MessageHeader&
    headers() const;

    virtual
    std::streamsize
    getContentLength() const;

protected:
    // construction

    PartSource();
    PartSource(const std::string& mediaType);
};

// direct descendants

class FilePartSource;
class PartStore;
class StringPartSource;

Detailed Documentation

This abstract class is used for adding parts or attachments to mail messages, as well as for uploading files as part of a HTML form.

Construction

PartSource()

Creates the PartSource, using the application/octet-stream MIME type.

PartSource(const std::string& mediaType)

Creates the PartSource, using the given MIME type.

Methods

virtual
std::istream&
stream() = 0

Returns an input stream for reading the part data.

Subclasses must override this method.

virtual
const std::string&
filename() const

Returns the filename for the part or attachment.

May be overridded by subclasses. The default implementation returns an empty string.

const std::string&
mediaType() const

Returns the MIME media type for this part or attachment.

MessageHeader&
headers()

Returns a MessageHeader containing additional header fields for the part.

const MessageHeader&
headers() const

Returns a MessageHeader containing additional header fields for the part.

virtual
std::streamsize
getContentLength() const

Returns the content length for this part which may be UNKNOWN_CONTENT_LENGTH if not available.