NAME

DwDispositionType -- Class representing a MIME content-disposition field body

SYNOPSIS

class DW_EXPORT DwDispositionType : public DwFieldBody {

public:

    DwDispositionType();
    DwDispositionType(const DwDispositionType& aDispType);
    DwDispositionType(const DwString& aStr, DwMessageComponent* aParent=0);
    virtual ~DwDispositionType();
    const DwDispositionType& operator = (const DwDispositionType& aDispType);
    virtual void Parse();
    virtual void Assemble();
    virtual DwMessageComponent* Clone() const;
    int DispositionType() const;
    void SetDispositionType(int aType);
    const DwString& DispositionTypeStr() const;
    void SetDispositionTypeStr(const DwString& aStr);
    const DwString& Filename() const;
    void SetFilename(const DwString& aStr);
    DwParameter* FirstParameter() const;
    void AddParameter(DwParameter* aParam);
    static DwDispositionType* NewDispositionType(const DwString& aStr,
        DwMessageComponent* aParent);
    static DwDispositionType* (*sNewDispositionType)(const DwString&,
        DwMessageComponent*);

protected:

    void _AddParameter(DwParameter* aParam);
    virtual void EnumToStr();
    virtual void StrToEnum();
    void DeleteParameterList();
    void CopyParameterList(DwParameter* aFirst);
    int mDispositionType;
    DwString mDispositionTypeStr;
    DwString mFilenameStr;
    DwParameter* mFirstParameter;

public:

    virtual void PrintDebugInfo(ostream& aStrm, int aDepth=0) const;
    virtual void CheckInvariants() const;

protected:

    void _PrintDebugInfo(ostream& aStrm) const;
};

DESCRIPTION

DwDispositionType represents a field body for the Content-Disposition header field as described in RFC-1806. This header field specifies whether the content of a message or body part should be displayed automatically to a user. A disposition-type of inline indicates that the content should be displayed; a disposition-type of attachment indicates that it should not be. RFC-1806 specifies that a filename parameter may be optionally included in the field body; the filename parameter suggests a file name for saving the message or body part's content.

DwDispositionType provides convenience functions that allow you to set or get the disposition-type as an enumerated value, to set or get the filename parameter, or to manage a list of parameters.

RFC-1806 specifically states that the Content-Disposition header field is experimental and not a proposed standard.

Public Member Functions

DwDispositionType()
DwDispositionType(const DwDispositionType& aDispType)
DwDispositionType(const DwString& aStr, DwMessageComponent* aParent=0)

The first constructor is the default constructor, which sets the DwDispositionType object's string representation to the empty string and sets its parent to NULL.

The second constructor is the copy constructor, which performs deep copy of aDispType. The parent of the new DwDispositionType object is set to NULL.

The third constructor copies aStr to the DwDispositionType object's string representation and sets aParent as its parent. The virtual member function Parse() should be called immediately after this constructor in order to parse the string representation. Unless it is NULL, aParent should point to an object of a class derived from DwField.

const DwDispositionType& operator = (const DwDispositionType& aDispType)

This is the assignment operator, which performs a deep copy of aDispType. The parent node of the DwDipositionType object is not changed.

virtual void Parse()

This virtual function, inherited from DwMessageComponent, executes the parse method for DwDispositionType objects. It should be called immediately after the string representation is modified and before the parts of the broken-down representation are accessed.

This function clears the is-modified flag.

virtual void Assemble()

This virtual function, inherited from DwMessageComponent, executes the assemble method for DwDispositionType objects. It should be called whenever one of the object's attributes is changed in order to assemble the string representation from its broken-down representation. It will be called automatically for this object by the parent object's Assemble() member function if the is-modified flag is set.

This function clears the is-modified flag.

virtual DwMessageComponent* Clone() const

This virtual function, inherited from DwMessageComponent, creates a new DwDispositionType object on the free store that has the same value as this DwDispositionType object. The basic idea is that of a virtual copy constructor.

int DispositionType() const

Returns the disposition-type as an enumerated value. Valid enumerated types, which are defined in enum.h, include DwMime::kDispTypeNull, DwMime::kDispTypeUnknown, DwMime::kDispTypeInline, and DwMime::kDispTypeAttachment.

void SetDispositionType(int aType)

Sets the disposition-type from the enumerated value aType. Valid enumerated types, which are defined in enum.h, include DwMime::kDispTypeNull, DwMime::kDispTypeUnknown, DwMime::kDispTypeInline, and DwMime::kDispTypeAttachment.

const DwString& DispositionTypeStr() const

Returns the disposition-type as a string.

void SetDispositionTypeStr(const DwString& aStr)

Sets the disposition-type from a string.

const DwString& Filename() const

This convenience function returns the value from the filename parameter, if present. If no filename parameter is present, an empty string is returned.

void SetFilename(const DwString& aStr)

This convenience function sets the value of the filename parameter to aStr.

DwParameter* FirstParameter() const

Returns the first DwParameter object in the list managed by this DwDispositionType object, or NULL if no parameters are present. Use DwParameter::Next() to iterate through the list.

void AddParameter(DwParameter* aParam)

Adds a DwParameter object to the list managed by this DwDispositionType object.

static DwDispositionType* NewDispositionType(const DwString& aStr, DwMessageComponent* aParent)

Creates a new DwDispositionType object on the free store. If the static data member sNewDispositionType is NULL, this member function will create a new DwDispositionType and return it. Otherwise, NewDispositionType() will call the user-supplied function pointed to by sNewDispositionType, which is assumed to return an object from a class derived from DwDispositionType, and return that object.

Public Data Members

static DwDispositionType* (*sNewDispositionType)(const DwString&, DwMessageComponent*)

If sNewDispositionType is not NULL, it is assumed to point to a user-supplied function that returns an object from a class derived from DwDispositionType.