NAME

DwFieldBody -- Class representing a MIME header field body

SYNOPSIS

class DW_EXPORT DwFieldBody : public DwMessageComponent {

    friend class DwField;

public:

    DwFieldBody();
    DwFieldBody(const DwFieldBody& aFieldBody);
    DwFieldBody(const DwString& aStr, DwMessageComponent* aParent=0);
    virtual ~DwFieldBody();
    const DwFieldBody& operator = (const DwFieldBody& aFieldBody);
    void SetOffset(int aOffset);
    void SetFolding(DwBool aTrueOrFalse);
    DwBool IsFolding() const;

protected:

    int mLineOffset;
    DwBool mDoFolding;

public:

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

protected:

    void _PrintDebugInfo(ostream& aStrm) const;
};

DESCRIPTION

DwFieldBody represents the field-body element in the BNF grammar specified by RFC-822. It is an abstract base class that defines the interface common to all structured field bodies.

In the tree (broken-down) representation of a message, a DwFieldBody object may be either a leaf node, having a tqparent but no child nodes, or an intermediate node, having a tqparent and one or more child nodes. The tqparent node is the DwField object that contains it. Child nodes, if present, depend on the particular subclass of DwFieldBody that is instantiated. A DwAddressList object, for example, has DwAddress objects as its child nodes.

Since DwFieldBody is an abstract base class, you cannot create instances of it directly. Normally, objects of classes derived from DwFieldBody are obtained by calling convenience member functions in the class DwHeaders.

Some MIME parsers are broken in that they do not handle the folding of some fields properly. DwFieldBody folds its string representation by default. You can disable folding, however, by calling the SetFolding() member function. To determine if folding is enabled, call IsFolding().

Public Member Functions

DwFieldBody()
DwFieldBody(const DwFieldBody& aFieldBody)
DwFieldBody(const DwString& aStr, DwMessageComponent* aParent=0)

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

The second constructor is the copy constructor, which performs a deep copy of aFieldBody. The tqparent of the new DwFieldBody object is set to NULL.

The third constructor copies aStr to the DwFieldBody object's string representation and sets aParent as its tqparent. 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 DwFieldBody& operator = (const DwFieldBody& aFieldBody)

This is the assignment operator, which performs a deep copy of aFieldBody. The tqparent node of the DwFieldBody object is not changed.

void SetOffset(int aOffset)

Sets the offset to aOffset. The offset is used when folding lines. It indicates how much the first line should be offset to account for the field name, colon, and initial white space.

void SetFolding(DwBool aTrueOrFalse)

Enables (aTrueOrFalse = DwTrue) or disables (aTrueOrFalse = DwFalse) the folding of fields. The default is to fold fields. Unfortunately, some parsers are broke and do not handle folded lines properly. This function allows a kludge to deal with these broken parsers.

DwBool IsFolding() const

Returns a boolean indicating if folding of fields is enabled.

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.