NAME

DwMsgId -- Class representing an RFC-822 msg-id

SYNOPSIS

class DW_EXPORT DwMsgId : public DwFieldBody {

public:

    DwMsgId();
    DwMsgId(const DwMsgId& aMsgId);
    DwMsgId(const DwString& aStr, DwMessageComponent* aParent=0);
    virtual ~DwMsgId();
    const DwMsgId& operator = (const DwMsgId& aMsgId);
    virtual void Parse();
    virtual void Assemble();
    virtual DwMessageComponent* Clone() const;
    virtual void CreateDefault();
    const DwString& LocalPart() const;
    void SetLocalPart(const DwString& aLocalPart);
    const DwString& Domain() const;
    void SetDomain(const DwString& aDomain);
    static DwMsgId* NewMsgId(const DwString& aStr,
        DwMessageComponent* aParent);
    static DwMsgId* (*sNewMsgId)(const DwString&, DwMessageComponent*);
    static const char* sHostName;

public:

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

protected:

    void _PrintDebugInfo(ostream& aStrm) const;
};

DESCRIPTION

DwMsgId represents a msg-id as described in RFC-822. In the BNF grammar in RFC-822, a msg-id has a local-part and a domain. In MIME++, a DwMsgId contains strings that contain the local-part and the domain.

In the tree (broken-down) representation of message, a DwMsgId object may only be a leaf node, having a parent but no child nodes. Its parent node must be a DwField object.

DwMsgId has member functions for getting or setting its local-part and its domain. You can have the library to create the contents of a DwMsgId object for you by calling the member function CreateDefault().

Public Member Functions

DwMsgId()
DwMsgId(const DwMsgId& aMsgId)
DwMsgId(const DwString& aStr, DwMessageComponent* aParent=0)

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

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

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

virtual void Parse()

This virtual function, inherited from DwMessageComponent, executes the parse method for DwMsgId objects. The parse method parses the local-part and the domain from the string representation.

You should call this member function after you set or modify the string representation, and before you retrieve local-part or domain.

This function clears the is-modified flag.

virtual void Assemble()

This virtual function, inherited from DwMessageComponent, executes the assemble method for DwMsgId objects. The assemble method creates or updates the string representation from the local-part and the domain.

You should call this member function after you modify the local-part or the domain, and before you retrieve the string representation.

This function clears the is-modified flag.

virtual DwMessageComponent* Clone() const

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

virtual void CreateDefault()

Creates a value for the msg-id. Uses the current time, process id, and fully qualified domain name for the host.

const DwString& LocalPart() const

Returns the local-part of the msg-id.

void SetLocalPart(const DwString& aLocalPart)

Sets the local-part of the msg-id.

const DwString& Domain() const

Returns the domain of the msg-id.

void SetDomain(const DwString& aDomain)

Sets the domain of the msg-id.

static DwMsgId* NewMsgId(const DwString& aStr, DwMessageComponent* aParent)

Creates a new DwMsgId object on the free store. If the static data member sNewMsgId is NULL, this member function will create a new DwMsgId and return it. Otherwise, NewMsgId() will call the user-supplied function pointed to by sNewMsgId, which is assumed to return an object from a class derived from DwMsgId, 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 DwMsgId* (*sNewMsgId)(const DwString&, DwMessageComponent*)

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

static const char* sHostName

Host name of machine, used to create msg-id string. This data member is ignored if the platform supports a gethostname() function call.