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

Stamp Class Reference

Inheritance diagram for Stamp:

FieldBody Node List of all members.

Detailed Description

Stamp represents a field body for the "Received" header field as described in RFC 2821 and RFC 2822. (RFC 2821 uses the term time stamp to describe the contents of the "Received" header field.) One "Received" header field is normally added by every host that relays a message through the transport system, as required by SMTP. The field includes a time stamp indicating the time that the message was received at the host, and possibly other information.

The "Received" header field provides information that may be helpful in resolving mail delivery problems. In practice, though, the most recent time stamp is often used by email client applications to obtain the time that the message was received by that client's mail server. The other information provided in the "Received" header field is optional and inconsistent between implementations. Some implementations do not provide much of the optional information, while other implementations provide it in non-standard forms.

The following is a sample time stamp line, which shows all the optional information:

    Received: from xyz.net by mx.org via TELENET with SMTP
        id M12345 for smith@aol.com ; Tue, 6 Oct 1998 09:23:59 -0700

Stamp provides access to all the information provided in a "Received" header field body, including sending host ("xyz.net"), receiving host ("mx.org"), physical mechanism ("TELENET"), protocol ("SMTP"), internal message identifier ("M12345"), original addressee ("smith\@aol.com"), and date/time the message was received ("Tue, 6 Oct 1998 09:23:59 -0700"). If an optional field is not present, then the "getter" function for that field returns an empty string.

Stamp follows the protocol for parse() and assemble() as required by Node.

Note: Because of inconsistencies in many server implementations, the parsing may not be reliable enough for applications to depend on. The only parsed information that you should probably rely on is the final date/time stamp. RFC 2821 suggests that the "Received" header field is intended mostly for inspection by mail system administrators to resolve mail delivery problems.


Public Member Functions

 Stamp ()
 Default constructor.
 Stamp (const Stamp &other)
 Copy constructor.
 Stamp (const String &str, Node *parent=0)
 Constructor that takes an initial string and parent node.
virtual ~Stamp ()
 Destructor.
const Stampoperator= (const Stamp &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 Stringfrom () const
 Gets the sending host.
void setFrom (const String &sendingHost)
 Sets the sending host.
const Stringby () const
 Gets the receiving host.
void setBy (const String &receivingHost)
 Sets the receiving host.
const Stringvia () const
 Gets the physical mechanism.
void setVia (const String &mechanism)
 Sets the physical mechanism.
const Stringwith () const
 Gets the protocol.
void setWith (const String &protocol)
 Sets the protocol.
const Stringid () const
 Gets the internal message identifier.
void setId (const String &id)
 Sets the internal message identifier.
const Stringfor_ () const
 Gets the original addressee.
void setFor (const String &addressee)
 Sets the original addressee.
DateTimedate ()
 Gets the date and time.
void setDate (const DateTime &date)
 Sets the date and time.

Static Public Member Functions

StampnewStamp ()
 Creates a new instance.

Static Public Attributes

Stamp *(* sNewStamp )()
 Provides a class factory hook.


Constructor & Destructor Documentation

Stamp  ) 
 

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

Stamp const Stamp other  ) 
 

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

Parameters:
other Stamp instance to copy

Stamp const String str,
Node parent = 0
 

This constructor sets the Stamp 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

~Stamp  )  [virtual]
 

Destructor


Member Function Documentation

void assemble  )  [virtual]
 

This virtual function, inherited from Node, executes the assemble operation for Stamp objects. The assemble operation creates or updates the string representation from the broken-down representation. For Stamp objects, the assemble operation builds the string representation from the Stamp object's attributes. Before it builds the string representation, this member function first calls the assemble() member function of the object's contained DateTime object.

You should call this member function after you set or modify any of the attributes of this Stamp object, and before you retrieve the string representation.

This function clears the is-modified flag.

Reimplemented from FieldBody.

const String & by  )  const
 

Gets the receiving host.

The receiving host is the host that added this field to the message headers. In the "Received" header field, the receiving host follows the "by" keyword. If the receiving host is not present, this function returns an empty string.

Returns:
the receiving host

Node * clone  )  const [virtual]
 

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

Returns:
a copy of this object

Reimplemented from FieldBody.

DateTime & date  ) 
 

Gets the date and time that the message was received.

This information is the only required information in the "Received" header field.

Returns:
date and time the message was received

const String & for_  )  const
 

Gets the original addressee.

This information may be important if some kind of address translation occurs. In the "Received" header field, the addressee follows the "for" keyword. If the original addressee is not present, this function returns an empty string.

Returns:
addressee

const String & from  )  const
 

Gets the sending host.

In the "Received" header field, the sending host follows the "from" keyword. If the sending host is not present, this function returns an empty string.

Returns:
the sending host

const String & id  )  const
 

Gets the internal message identifier.

This is a value that is meaningful to the receiving host, such as the name of a file that was used to temporarily store the message. In the "Received" header field, the identifier follows the "id" keyword. If the identifier is not present, this function returns an empty string.

Returns:
identifier

Stamp * newStamp  )  [static]
 

Creates a new Stamp object.

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

Returns:
new Stamp instance
See also:
sNewStamp

const Stamp & operator= const Stamp other  ) 
 

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

Parameters:
other Stamp instance to copy

void parse  )  [virtual]
 

This virtual function, inherited from Node, executes the parse operation for Stamp objects. The parse operation creates or updates the broken-down representation from the string representation. For Stamp objects, the parse operation parses the string representation to extract the from, by, via, with, id, for, and date attributes. This member function also calls the parse() member function of its contained DateTime object.

You should call this member function after you set or modify the string representation, and before you access any of the attributes of this object.

This function clears the is-modified flag.

Reimplemented from FieldBody.

void setBy const String receivingHost  ) 
 

Sets the receiving host.

Parameters:
receivingHost the receiving host

void setDate const DateTime date  ) 
 

Sets the date and time that the message was received.

Parameters:
date date and time the message was received

void setFor const String addressee  ) 
 

Sets the original addressee.

Parameters:
addressee the addressee

void setFrom const String sendingHost  ) 
 

Sets the sending host.

Parameters:
sendingHost the sending host

void setId const String id  ) 
 

Sets the internal message identifier.

Parameters:
id identifier

void setVia const String mechanism  ) 
 

Sets the physical mechanism.

Parameters:
mechanism the physical mechanism

void setWith const String protocol  ) 
 

Sets the protocol.

Parameters:
protocol the protocol

const String & via  )  const
 

Gets the physical mechanism.

In the "Received" header field, the physical mechanism follows the "via" keyword. If the physical mechanism is not present, this function returns an empty string.

Returns:
the physical mechanism

const String & with  )  const
 

Gets the protocol that was used to send this message (that is, the protocol by which the receiving host received it).

In the "Received" header field, the protocol follows the "with" keyword. Usually, the protocol is SMTP or ESMTP. If the protocol is not present, this function returns an empty string.

Returns:
the protocol


Member Data Documentation

Stamp *(* sNewStamp)()=0 [static]
 

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

See also:
newStamp()

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