Class Address.

Inherits Garbage

The Address class represents one e-mail address.

All aspects of e-mail addresses are emulated, mostly except address groups.

Address groups can exist, but only as empty groups ("internet-drafts:;"). (An empty address group is an address with a name() but without a localpart() or a domain().)

The un-address <> can be parsed and represented; both its name(), localpart() and domain() are empty. Local-only addresses (e.g. "root") are accepted, because so much legacy software generated it, and some even generates it still.

Domains are kept as naked strings, and there is as yet no attempt to make this fit nicely in the database.

Address::Address( const Address & other )

Constructs a copy of other.

Address::Address( const EString & n, const EString & l, const EString & o )

Constructs an address whose display-name is n (which must be in ASCII), whose localpart is l and whose domain is o.

Address::Address( const UString & n, const EString & l, const EString & o )

Constructs an address whose display-name is n, whose localpart is l and whose domain is o.

Address::Address( const char * n, const EString & l, const EString & o )

Constructs an address whose display-name is n (which must be in ASCII), whose localpart is l and whose domain is o.

Address::Address()

Constructs an empty invalid Address.

Reimplements Garbage::Garbage().

EString Address::domain() const

Returns the domain stored in this Address. In case of a memberless group, domain() returns an empty string.

EString Address::error() const

Returns whatever setError() set, or an empty string.

uint Address::id() const

Returns the numeric ID of this address object in the database, or 0 if it is not known.

void Address::init( const UString & n, const EString & l, const EString & o )

This private function contains the shared part of the constructors, initialising the object with the display-name n, localpart l, and domain o and an appropriate type(). Uses a cache to try to share the id() with other instances of the same address.

EString Address::localpart() const

Returns the localpart stored in this Address. In case of a memberless group, localpart() returns an empty string.

bool Address::localpartIsSensible() const

Returns true if this is a sensible-looking localpart, and false if it needs quoting. We should never permit one of our users to need quoting, but we must permit foreign addresses that do.

EString Address::lpdomain() const

Returns the localpart and domain as a EString. Returns toString() if the type() isn't Normal or Local.

EString Address::name() const

Returns the name stored in this Address. The name is the RFC 2822 display-part, or in case of memberless groups, the display-name of the group.

A memberless group is stored as an Address whose localpart() and domain() are both empty.

void Address::setError( const EString & message )

Records message as an error message relating to the parsing of this Address. The initial value is empty.

void Address::setId( uint id )

Sets the numeric ID of this address object to id. This is only meant to be used by the AddressQuery class when it retrieves the ID from the database.

EString Address::toString() const

Returns an RFC 2822 representation of this address.

Address::Type Address::type() const

Returns the type of Address, which is inferred at construction time.

If type() is Normal, name(), localpart() and domain() are valid. If type() is EmptyGroup, name() alone is. If type() is Bounce or Invalid, none of the three are.

UString Address::uname() const

Returns the canonical name belonging to this address.

void Address::uniquify( List<Address> * l )

Removes any addresses from l that exist twice in the list.

bool Address::valid() const

Returns true if this Address is a meaningful object, or false if its content is meaningless.

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.