## NAME

DwMessage -- Class representing an RFC-822/MIME message

## SYNOPSIS

    class DW_EXPORT DwMessage : public DwEntity {

    public:

        DwMessage();
        DwMessage(const DwMessage& aMessage);
        DwMessage(const DwString& aStr, DwMessageComponent* aParent=0);
        virtual ~DwMessage();
        const DwMessage& operator = (const DwMessage& aMessage);
        virtual DwMessageComponent* Clone() const;
        static DwMessage* NewMessage(const DwString& aStr,
            DwMessageComponent* aParent);
        static DwMessage* (*sNewMessage)(const DwString&, DwMessageComponent*);

    public:

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

    protected:

        void _PrintDebugInfo(ostream& aStrm) const;
    };

## DESCRIPTION

`DwMessage` represents an RFC-822/MIME message.

A message contains both a collection of header fields and a body. In the terminology of RFC-2045, the general term for the headers-body combination is entity. In MIME++, `DwMessage` is a direct subclass of `DwEntity`, and therefore contains both a `DwHeaders` object and a `DwBody` object.

In the tree (broken-down) representation of message, a `DwMessage` object is almost always a root node, having child nodes but no parent node. The child nodes are the `DwHeaders` object and the `DwBody` object it contains. A `DwMessage` may sometimes be an intermediate node. In this special case, the parent node is a `DwBody` object of type "message/*" and the `DwMessage` object represents an encapsulated message.

To access the contained `DwHeaders` object, use the inherited member function `DwEntity::Headers()`. To access the contained `DwBody` object, use the inherited member function `DwEntity::Body()`.

## Public Member Functions

DwMessage()
DwMessage(const DwMessage& aMessage)
DwMessage(const DwString& aStr, DwMessageComponent* aParent=0)

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

The second constructor is the copy constructor, which performs a deep copy of `aMessage`. The parent of the new `DwMessage` object is set to `NULL`.

The third constructor copies `aStr` to the `DwMessage` 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.

const DwMessage& operator = (const DwMessage& aMessage)

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

virtual DwMessageComponent* Clone() const

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

static DwMessage* NewMessage(const DwString& aStr, DwMessageComponent* aParent)

Creates a new `DwMessage` object on the free store. If the static data member `sNewMessage` is `NULL`, this member function will create a new `DwMessage` and return it. Otherwise, `NewMessage()` will call the user-supplied function pointed to by `sNewMessage`, which is assumed to return an object from a class derived from `DwMessage`, 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.

## Public Data Members

static DwMessage* (*sNewMessage)(const DwString&, DwMessageComponent*)

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