## NAME

DwMechanism -- Class representing a MIME content-transfer-encoding field-body

## SYNOPSIS

    class DW_EXPORT DwMechanism : public DwFieldBody {

    public:

        DwMechanism();
        DwMechanism(const DwMechanism& aCte);
        DwMechanism(const DwString& aStr, DwMessageComponent* aParent=0);
        virtual ~DwMechanism();
        const DwMechanism& operator = (const DwMechanism& aCte);
        virtual void Parse();
        virtual void Assemble();
        virtual DwMessageComponent* Clone() const;
        int AsEnum() const;
        void FromEnum(int aCte);
        static DwMechanism*
            NewMechanism(const DwString& aStr, DwMessageComponent* aParent);
        static DwMechanism*
            (*sNewMechanism)(const DwString&, DwMessageComponent*);

    public:

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

    protected:

        void _PrintDebugInfo(ostream& aStrm) const;
    };

## DESCRIPTION

`DwMechanism` represents a field body for the Content-Transfer-Encoding header field as described in RFC-2045. `DwMechanism` provides convenience functions that allow you to set or get the content-transfer-encoding attribute as an enumerated value.

## Public Member Functions

DwMechanism()
DwMechanism(const DwMechanism& aCte)
DwMechanism(const DwString& aStr, DwMessageComponent* aParent=0)

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

The second constructor is the copy constructor, which copies the string representation from `aCte`. The parent of the new `DwMechanism` object is set to `NULL`.

The third constructor copies `aStr` to the `DwMechanism` 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 DwMechanism& operator = (const DwMechanism& aCte)

This is the assignment operator, which performs a deep copy of `aCte`. The parent node of the `DwMechanism` object is not changed.

virtual void Parse()

This virtual function, inherited from `DwMessageComponent`, executes the parse method for `DwMechanism` objects. It should be called immediately after the string representation is modified and before any of the object's attributes are retrieved.

This function clears the is-modified flag.

virtual void Assemble()

This virtual function, inherited from `DwMessageComponent`, executes the assemble method for `DwMechanism` objects. It should be called whenever one of the object's attributes is changed in order to assemble the string 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 `DwMechanism` object on the free store that has the same value as this `DwMechanism` object. The basic idea is that of a virtual copy constructor.

int AsEnum() const

Returns the content transfer encoding as an enumerated value. Enumerated values are defined for all standard content transfer encodings in the file enum.h. If the content transfer encoding is non-standard `DwMime::kCteUnknown` is returned. The inherited member function `DwMessageComponent::AsString()` may be used to get the content transfer encoding, standard or non-standard, as a string.

void FromEnum(int aCte)

Sets the content transfer encoding from an enumerated value. Enumerated values are defined for all standard content transfer encodings in the file enum.h. You may set the content transfer encoding to any string value, standard or non-standard, by using the inherited member function `DwMessageComponent::FromString()`.

static DwMechanism* NewMechanism(const DwString& aStr, DwMessageComponent* aParent)

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

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

This virtual function, inherited from `DwMessageComponent`, prints debugging information about this object to `aStrm`. It will also call `PrintDebugInfo()` for any of its child components down to a level of `aDepth`.

This member function is available only in the debug version of the library.

virtual void CheckInvariants() const

Aborts if one of the invariants of the object fails. Use this member function to track down bugs.

This member function is available only in the debug version of the library.

## Public Data Members

static DwMechanism* (*sNewMechanism)(const DwString&, DwMessageComponent*)

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