Main Page | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

MsgId Class Reference

Inheritance diagram for MsgId:

FieldBody Node List of all members.

Detailed Description

MsgId represents a message ID as described in RFC 2822. A message ID appears as the field body of the "%Message-ID" header field, and has a local part and a domain separated by an "at" sign. The following is an example of a "%Message-ID" header field:

    Message-ID: <994590483.5890@somehost.net>

In the above example, the local part is "994590483.5890" and the domain is "somehost.net". In MIME body parts, a message ID can also appear as the field body of the "Content-ID" header field.

In Hunny MIME++, a MsgId contains strings for the local part and the domain.

In the document tree representation of a message, a MsgId object may only be a leaf node, having a parent but no child nodes.

MsgId has member functions for getting or setting its local part and its domain.

MsgId also has a few convenience functions. You may call the member function createLocalPart() to have the library to set a unique local part for you. You may call the member function createDomain() to have the library to set the domain from the default domain. You may call the member function createDefault() to have the library set both the local part and the domain (equivalent to calling createLocalPart() and createDomain()).

You may set the default domain by calling the static member function setDefaultDomain()


Public Member Functions

 MsgId ()
 Default constructor.
 MsgId (const MsgId &other)
 Copy constructor.
 MsgId (const String &str, Node *parent=0)
 Constructor that takes an initial string and parent node.
virtual ~MsgId ()
 Destructor.
const MsgIdoperator= (const MsgId &other)
 Assignment operator.
virtual void parse ()
 Parses the string representation.
virtual void assemble ()
 Assembles the string representation.
virtual Nodeclone () const
 Creates a copy of this object.
const StringlocalPart () const
 Gets the local part.
void setLocalPart (const String &localPart)
 Sets the local part.
const Stringdomain () const
 Gets the domain.
void setDomain (const String &domain)
 Gets the domain.
virtual void createDefault ()
 Sets the local part and the domain to default values.
virtual void createLocalPart ()
 Sets the local part to a default value.
virtual void createDomain ()
 Sets the domain to a default value.

Static Public Member Functions

void setDefaultDomain (const char *domain)
 Sets the default value for the domain.
MsgIdnewMsgId ()
 Creates a new instance.

Static Public Attributes

MsgId *(* sNewMsgId )()
 Provides a class factory hook.

Static Protected Attributes

char * sDefaultDomain = 0
 Default value for the domain.


Constructor & Destructor Documentation

MsgId  ) 
 

This constructor sets the MsgId object's string representation to the empty string and sets its parent node to NULL.

MsgId const MsgId other  ) 
 

This constructor performs a deep copy of its argument. The parent node of the new MsgId object is set to NULL.

Parameters:
other MsgId instance to copy

MsgId const String str,
Node parent = 0
 

This constructor sets the MsgId object's string representation to str and sets its parent node to parent.

Normally, you call the virtual function parse() immediately after this constructor to create the broken-down representation.

Parameters:
str initial value for the string representation
parent parent node for this object

~MsgId  )  [virtual]
 

Destructor


Member Function Documentation

void assemble  )  [virtual]
 

This virtual function, inherited from Node, executes the assemble operation for MsgId objects. The assemble operation creates or updates the string representation from the broken-down representation. For MsgId objects, the assemble operation builds the string representation from the local part and the domain.

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

This function clears the is-modified flag.

Reimplemented from FieldBody.

Node * clone  )  const [virtual]
 

This virtual function, inherited from Node, creates a new MsgId object that has the same value as this MsgId object. The parent node of the new MsgId object is set to NULL.

Returns:
a copy of this object

Reimplemented from FieldBody.

void createDefault  )  [virtual]
 

Sets the local part and the domain to default values.

This convenience function is equivalent to calling createLocalPart() and createDomain().

See also:
createLocalPart()

createDomain()

void createDomain  )  [virtual]
 

Sets the domain to a default value.

You may call the static member function setDefaultDomain() to set the default value.

See also:
setDefaultDomain()

void createLocalPart  )  [virtual]
 

Sets the local part to a default value.

The created local part is unique to the local machine. The method creates the local part using the current time, the thread or process ID, and a thread-synchronized counter.

const mimepp::String & domain  )  const
 

Gets the domain.

Returns:
domain

const String & localPart  )  const
 

Gets the local part.

Returns:
local part

MsgId * newMsgId  )  [static]
 

Creates a new MsgId object.

If the static data member sNewMsgId is NULL, this member function creates a new MsgId object and returns it. Otherwise, newMsgId() calls the user-supplied function that sNewMsgId points to and returns the object created by that function.

Returns:
new MsgId instance
See also:
sNewMsgId

const MsgId & operator= const MsgId other  ) 
 

Performs a deep copy of its argument. The parent node of this MsgId object is not changed.

Parameters:
other MsgId instance to copy

void parse  )  [virtual]
 

This virtual function, inherited from Node, executes the parse operation for MsgId objects. The parse operation creates or updates the broken-down representation from the string representation. For MsgId objects, the parse operation parses the string representation to extract the local part and the domain.

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.

Reimplemented from FieldBody.

void setDefaultDomain const char *  domain  )  [static]
 

Sets the default domain. The member function createDomain() uses the value set by this static member function.

The library initialization function mimepp::Initialize() calls this member function to set the default domain. You may call this function from your own code to change the default domain.

Important: This static member function is not thread-safe. To use it safely in a multi-threaded application, you should call it at initialization time before threads are created.

See also:
createDomain()

void setDomain const String domain  ) 
 

Sets the domain.

Parameters:
domain domain

void setLocalPart const String localPart  ) 
 

Sets the local part.

Parameters:
localPart local part


Member Data Documentation

char * sDefaultDomain = 0 [static, protected]
 

Default value for the domain.

MsgId *(* sNewMsgId)()=0 [static]
 

If sNewMsgId is not NULL, it must point to a user-supplied function that returns a new instance of a subclass of MsgId.

See also:
newMsgId()

Copyright © 2001-2007 Hunny Software, Inc. All rights reserved.