AddressList Class Reference

Class that represents a list of RFC 2822 mail addresses More...

Inheritance diagram for AddressList:

FieldBody Node

List of all members.

Public Member Functions

 AddressList ()
 Default constructor.
 AddressList (const AddressList &other)
 Copy constructor.
 AddressList (const String &str, Node *parent=0)
 Constructor that takes an initial string and parent node.
virtual ~AddressList ()
 Destructor.
const AddressListoperator= (const AddressList &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.
int numAddresses () const
 Gets the number of addresses in the list.
void addAddress (Address *address)
 Adds an address to the end of the list.
void deleteAllAddresses ()
 Deletes all addresses in the list.
AddressaddressAt (int index) const
 Gets the address at the specified position in the list.
void insertAddressAt (int index, Address *address)
 Inserts an address at the specified position in the list.
AddressremoveAddressAt (int index)
 Removes the address at the specified position in the list.

Static Public Member Functions

static AddressListnewAddressList ()
 Creates a new instance.

Static Public Attributes

static AddressList *(* sNewAddressList )()
 Provides a class factory hook.

Protected Member Functions

void _copyAddresses (const AddressList &list)
 Copies all addresses from another list.
void _addAddress (Address *address)
 Adds an address to the end of the list.
void _insertAddressAt (int index, Address *address)
 Inserts an address at the specified position in the list.
Address_removeAddressAt (int index)
 Removes the address at the specified position in the list.
void _deleteAllAddresses ()
 Deletes all addresses in the list.


Detailed Description

AddressList represents a list of mail addresses as described in RFC 2822. In Hunny MIME++, AddressList is a container for objects of type Address, and it contains various member functions to manage its contained objects. AddressList is also a FieldBody. This reflects the fact that certain RFC 2822 header fields, such as the "To" header field, have a list of addresses as their field bodies.

Constructor & Destructor Documentation

AddressList (  ) 

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

AddressList ( const AddressList other  ) 

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

Parameters:
other AddressList instance to copy

AddressList ( const String str,
Node parent = 0 
)

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

~AddressList (  )  [virtual]

Destructor


Member Function Documentation

void _addAddress ( Address address  )  [protected]

Same as addAddress(), but does not set the is-modified flag.

Parameters:
address Address object to add
See also:
addAddress()

void _copyAddresses ( const AddressList list  )  [protected]

Copies the list of Address objects from list. Assumes the list in this AddressList object is emtpy. Does not set the is-modified flag.

Parameters:
list AddressList object to copy Address objects from

void _deleteAllAddresses (  )  [protected]

Same as deleteAllAddresses(), but does not set the is-modified flag.

See also:
deleteAllAddresses()

void _insertAddressAt ( int  index,
Address addr 
) [protected]

Same as insertAddressAt(), but does not set the is-modified flag.

Parameters:
index position in the list to insert the Address object
addr Address object to insert
See also:
insertAddressAt()

Address * _removeAddressAt ( int  index  )  [protected]

Same as removeAddressAt(), but does not set the is-modified flag.

Parameters:
index position of the Address object to remove
Returns:
pointer to the removed Address object
See also:
removeAddressAt()

void addAddress ( Address address  ) 

Adds address to the end of the list.

The AddressList destructor deletes the Address objects in the list.

Parameters:
address Address object to add

Address & addressAt ( int  index  )  const

Gets the Address object at position index in the list.

The function's behavior is undefined if index is out of range. Valid values for index are 0 <= index < numAddresses().

Parameters:
index position of the Address object to get
Returns:
reference to the Address object at the specified position

void assemble (  )  [virtual]

This virtual function, inherited from Node, executes the assemble operation for AddressList objects. The assemble operation creates or updates the string representation from the broken-down representation. For AddressList objects, the assemble operation builds the string representation from the list of contained Address objects. Before it builds the string representation for the AddressList object, the function first calls the assemble() member function of each Address object in its list.

You should call this member function after you set or modify any of the contained Address objects, 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 AddressList object that has the same value as this AddressList object. The parent node of the new AddressList object is set to NULL.

Returns:
a copy of this object

Reimplemented from FieldBody.

void deleteAllAddresses (  ) 

Removes and deletes all Address objects in the list.

void insertAddressAt ( int  index,
Address address 
)

Inserts address into the list at position index.

If index is zero, then the function inserts address into the first position in the list. If index equals numAddresses(), then the function inserts address into the last position in the list. If index is less than numAddresses(), then the function moves the Address objects at position index or greater to a higher position in the list.

The AddressList destructor deletes the Address objects in the list.

The function's behavior is undefined if index is out of range. Valid values for index are 0 <= index <= numAddresses().

Parameters:
index position in the list to insert the Address object
address Address object to insert

AddressList * newAddressList (  )  [static]

Creates a new AddressList object.

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

Returns:
new AddressList instance
See also:
sNewAddressList

int numAddresses (  )  const

Gets the number of Address objects in the list.

Returns:
number of Address objects in the list

const AddressList & operator= ( const AddressList other  ) 

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

Parameters:
other AddressList instance to copy

void parse (  )  [virtual]

This virtual function, inherited from Node, executes the parse operation for AddressList objects. The parse operation creates or updates the broken-down representation from the string representation. For AddressList objects, the parse operation parses the string representation to create a list of Address objects. This member function also calls the parse() member function of each Address object in its list.

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

This function clears the is-modified flag.

Reimplemented from FieldBody.

Address * removeAddressAt ( int  index  ) 

Removes the Address object at position index from the list and returns it.

If index is less than numAddresses()-1, then the function moves the Address objects at position (index + 1) or greater to a lower position in the list.

The function's behavior is undefined if index is out of range. Valid values for index are 0 <= index < numAddresses().

Parameters:
index position of the Address object to remove
Returns:
pointer to the removed Address object


Member Data Documentation

AddressList *(* sNewAddressList)()=0 (  )  [static]

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

See also:
newAddressList()

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