DwBodyPart Man Page

## NAME

DwBodyPart -- Class representing a MIME body-part

## SYNOPSIS

    class DW_EXPORT DwBodyPart : public DwEntity {

    public:

        DwBodyPart();
        DwBodyPart(const DwBodyPart& aPart);
        DwBodyPart(const DwString& aStr, DwMessageComponent* aParent=0);
        virtual ~DwBodyPart();
        const DwBodyPart& operator = (const DwBodyPart& aPart);
        virtual DwMessageComponent* Clone() const;
        static DwBodyPart* NewBodyPart(const DwString& aStr,
            DwMessageComponent* aParent);
        DwBodyPart* Next() const;
        void SetNext(const DwBodyPart* aPart);
        static DwBodyPart* (*sNewBodyPart)(const DwString&, DwMessageComponent*);

    public:

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

    protected:

        void _PrintDebugInfo(ostream& aStrm) const;
    };

## DESCRIPTION

`DwBodyPart` represents a body part, as described in RFC-2045 and RFC-2046. A body part is an entity, so it has a collection of headers and a body. A body part is different from a message in that a body part is part of a multipart body.

In MIME++, a `DwBodyPart` is a subclass of `DwEntity`; therefore, it contains both a `DwHeaders` object and a `DwBody` object, and it is contained in a multipart `DwBody` object.

As with `DwMessage`, most of the functionality of `DwBodyPart` is implemented by the abstract class `DwEntity`.

## Public Member Functions

DwBodyPart()
DwBodyPart(const DwBodyPart& aPart)
DwBodyPart(const DwString& aStr, DwMessageComponent* aParent=0)

The first constructor is the default constructor, which sets the `DwBodyPart` 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 `aPart`. The parent of the new `DwBodyPart` object is set to `NULL`.

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

const DwBodyPart& operator = (const DwBodyPart& aPart)

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

virtual DwMessageComponent* Clone() const

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

static DwBodyPart* NewBodyPart(const DwString& aStr, DwMessageComponent* aParent)

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

DwBodyPart* Next() const

This member function returns the next `DwBodyPart` object following this `DwBodyPart` in the list of `DwBodyPart` objects contained in a multipart `DwBody`.

void SetNext(const DwBodyPart* aPart)

This advanced function sets `aPart` as the next `DwBodyPart` object following this `DwBodyPart` in the list of `DwBodyPart` objects contained in a multipart `DwBody`. Since `DwBody` contains a member function for adding a `DwBodyPart` object to its list, this function should be avoided for most applications.

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 DwBodyPart* (*sNewBodyPart)(const DwString&, DwMessageComponent*)

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