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

Body Class Reference

Inheritance diagram for Body:

Node List of all members.

Detailed Description

Body represents the body of a message or body part.

Using the terms defined in RFC 2045, an entity contains a collection of header fields and a body. A message is an entity. A body part is also an entity. In Hunny MIME++, an Entity object contains a Headers object and a Body object. Message is a subclass of Entity. BodyPart is also a subclass of Entity.

If the primary content type of an entity is "multipart" (for example, "multipart/mixed"), then the body contains one or more body parts. If the content type is "message/rfc822", then the body contains an encapsulated message. For any content type, the body contains a string of characters or bytes. In Hunny MIME++, if the entity's primary content type is "multipart", then the Body object contains a collection of BodyPart objects. If the entity's content type is "message/rfc822", then the Body object contains a single Message object. For any content type, including "multipart" and "message/rfc822", the Body contains a string of characters or bytes, which is its string representation.

In the document tree representation of a message, a Body object can be an intermediate node, having both a parent node and one or more child nodes, or a leaf node, having a parent but no child nodes. In either case, the parent node is the Entity object that contains it. If it is an intermediate node, it must be of type "multipart" with BodyPart objects as child nodes, or of type "message/rfc822" with a single Message object as its child node. (See the man page for Node for a discussion of the tree representation of a message.)

Normally, you do not create a Body object directly, but you access it through the Entity::body() member function of Entity, which creates the Body object for you.

To add a BodyPart to a multipart Body, call the member function addBodyPart() or insertBodyPartAt(). To get the number of body parts, call numBodyParts(). To access a particular body part, call bodyPartAt(). To remove a single body part without deleting it, call removeBodyPartAt(). To remove and delete all body parts, call deleteAllBodyParts().

To get the Message object contained in a Body object with "message/rfc822" content type, call message(). To set the contained message, call setMessage().


Public Member Functions

 Body ()
 Default constructor.
 Body (const Body &other)
 Copy constructor.
 Body (const String &str, Node *parent=0)
 Constructor that takes an initial string and parent node.
virtual ~Body ()
 Destructor.
const Bodyoperator= (const Body &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 numBodyParts () const
 Gets the number of body parts in the list.
void addBodyPart (BodyPart *part)
 Adds a body part to the end of the list.
void deleteAllBodyParts ()
 Deletes all body parts in the list.
BodyPartbodyPartAt (int index) const
 Gets the body part at the specified position in the list.
void insertBodyPartAt (int index, BodyPart *part)
 Inserts a body part at the specified position in the list.
BodyPartremoveBodyPartAt (int index)
 Removes the body part at the specified position in the list.
Messagemessage () const
 Gets the contained message.
void setMessage (class Message *message)
 Sets the contained message.
const Stringpreamble () const
 Gets the preamble of a multipart body.
void setPreamble (const String &str)
 Sets the preamble of a multipart body.
const Stringepilogue () const
 Gets the epilogue of a multipart body.
void setEpilogue (const String &str)
 Sets the epilogue of a multipart body.

Static Public Member Functions

BodynewBody ()
 Creates a new instance.

Static Public Attributes

Body *(* sNewBody )()
 Provides a class factory hook.

Protected Member Functions

void _copyBodyParts (const Body &body)
 Copies all body parts from another list.
void _addBodyPart (BodyPart *bart)
 Adds a body part to the end of the list.
void _insertBodyPartAt (int index, BodyPart *part)
 Inserts a body part at the specified position in the list.
BodyPart_removeBodyPartAt (int index)
 Removes the body part at the specified position in the list.
void _deleteAllBodyParts ()
 Deletes all body parts in the list.
void _setMessage (class Message *message)
 Sets the contained message.


Constructor & Destructor Documentation

Body  ) 
 

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

Body const Body other  ) 
 

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

Parameters:
other Body instance to copy

Body const String str,
Node parent = 0
 

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

~Body  )  [virtual]
 

Destructor


Member Function Documentation

void _addBodyPart BodyPart part  )  [protected]
 

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

See also:
addBodyPart()

void _copyBodyParts const Body body  )  [protected]
 

Copies the list of BodyPart objects from body. Assumes the list in this Body object is emtpy. Does not set the is-modified flag.

Parameters:
body Body object to copy BodyPart objects from

void _deleteAllBodyParts  )  [protected]
 

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

See also:
deleteAllBodyParts()

void _insertBodyPartAt int  index,
BodyPart part
[protected]
 

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

See also:
insertBodyPartAt()

BodyPart * _removeBodyPartAt int  index  )  [protected]
 

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

See also:
removeBodyPartAt()

void _setMessage class Message message  )  [protected]
 

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

Parameters:
message the Message object

void addBodyPart BodyPart part  ) 
 

Adds part to the end of the body part list.

The Body destructor deletes the BodyPart objects in the list.

Parameters:
part BodyPart object to add

void assemble  )  [virtual]
 

This virtual function, inherited from Node, executes the assemble operation for Body objects. The assemble operation creates or updates the string representation from the broken-down representation. If the content type of the containing entity is "multipart", then the assemble operation updates the string representation from the list of BodyPart objects that the Body contains. If the content type is "message/rfc822", then the assemble operation updates the string representation from the Message object that the Body contains. If the content type is not "multipart" or "message/rfc822", then the assemble operation does nothing.

Note: If the Body object has no parent node -- that is, it is not contained by an Entity object -- then the assemble operation does nothing, since it is unable to determine the content type.

You should call this member function after you add a BodyPart object to a multipart body, or add a Message object to a message body, and before you access the object's string representation.

This function clears the is-modified flag.

Implements Node.

BodyPart & bodyPartAt int  index  )  const
 

Gets the BodyPart object at position index in the body part list.

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

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

Node * clone  )  const [virtual]
 

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

Returns:
a copy of this object

Implements Node.

void deleteAllBodyParts  ) 
 

Removes and deletes all BodyPart objects in the body part list.

const String & epilogue  )  const
 

Gets the epilogue for a multipart body.

The epliogue is the part of the body that follows the last body part. It is not normally shown in a message viewer, and is empty in most messages.

Returns:
the epilogue of the body

void insertBodyPartAt int  index,
BodyPart part
 

Inserts part into the body part list at position index.

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

The Body destructor deletes the BodyPart objects in the list.

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

Parameters:
index position in the list to insert the BodyPart object
part BodyPart object to insert

Message * message  )  const
 

Gets the contained Message object.

Returns:
contained Message; or NULL if there is no Message

Body * newBody  )  [static]
 

Creates a new Body object.

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

Returns:
new Body instance
See also:
sNewBody

int numBodyParts  )  const
 

Gets the number of BodyPart objects in the body part list.

Returns:
number of BodyPart objects in the list

const Body & operator= const Body other  ) 
 

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

Parameters:
other Body instance to copy

void parse  )  [virtual]
 

This virtual function, inherited from Node, executes the parse operation for Body objects. The parse operation creates or updates the broken-down representation from the string representation. If the content type of the containing entity is "multipart", the parse operation creates a list of BodyPart objects to represent the body parts that the body contains. If the content type is "message/rfc822", the parse operation creates a single Message object to represent the encapsulated message. If the content type is not "multipart" or "message/rfc822", the parse operation does nothing.

Note: If the Body object has no parent node -- that is, it is not contained by an Entity object -- then the parse operation does nothing, since it is unable to determine the content type.

You should call this member function after you set or modify the string representation, and before you access a contained BodyPart or Message.

This function clears the is-modified flag.

Implements Node.

const String & preamble  )  const
 

Gets the preamble for a multipart body.

The preamble is the part of the body that precedes the first body part. It is not normally shown in a message viewer, and usually contains a message that's meaningful to users of non-MIME capable message viewers.

Returns:
the preamble of the body

BodyPart * removeBodyPartAt int  index  ) 
 

Removes the BodyPart object at position index from the body part list and returns it.

If index is less than numBodyParts()-1, then the function moves the BodyPart 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 < numBodyParts().

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

void setEpilogue const String epilogue  ) 
 

Sets the epliogue for a multipart body.

The epilogue is the part of the body that follows the last body part. It is not normally shown in a message viewer, and is empty in most messages.

Parameters:
epilogue the epilogue of the body

void setMessage class Message message  ) 
 

Sets the contained Message object.

The Message object will be destroyed by the Body object's destructor.

Parameters:
message the Message object

void setPreamble const String preamble  ) 
 

Sets the preamble for a multipart body.

The preamble is the part of the body that precedes the first body part. It is not normally shown in a message viewer, and usually contains a message that's meaningful to users of non-MIME capable message viewers.

Parameters:
preamble the preamble of the body


Member Data Documentation

Body *(* sNewBody)()=0 [static]
 

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

See also:
newBody()

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