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

Field Class Reference

Inheritance diagram for Field:

Node List of all members.

Detailed Description

Field represents a header field as described in RFC 2822. According to RFC 2822, a header field contains a field name and a field body. In Hunny MIME++, a Field contains two elements: a String that contains its field name and a FieldBody object that represents its field body.

In the document tree representation of a message, a Field object is always an intermediate node, having a parent node and a single child node. The parent node is the Headers object that contains it. The child node is the FieldBody object it contains.

To get or set the field name, use the member functions fieldName() and setFieldName(). To get or set the contained FieldBody object, use fieldBody() and setFieldBody().


Public Member Functions

 Field ()
 Default constructor.
 Field (const Field &other)
 Copy constructor.
 Field (const String &str, Node *parent=0)
 Constructor that takes an initial string and parent node.
virtual ~Field ()
 Destructor.
const Fieldoperator= (const Field &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 StringfieldName () const
 Gets the field name.
void setFieldName (const String &str)
 Sets the field name.
FieldBodyfieldBody () const
 Gets the field body.
void setFieldBody (class FieldBody *fieldBody)
 Sets the field body.

Static Public Member Functions

FieldBodycreateFieldBody (const String &fieldName, const String &fieldBody, Node *parent)
 Creates an instance of a subclass of FieldBody.
FieldBody_createFieldBody (const String &fieldName, const String &fieldBody, Node *parent)
 Default factory function for creating FieldBody instances.
FieldnewField ()
 Creates a new instance.

Static Public Attributes

FieldBody *(* sCreateFieldBody )(const String &fieldName, const String &fieldBody, Node *parent)
 Factory function hook for creating FieldBody instances.
Field *(* sNewField )()
 Provides a class factory hook.

Protected Member Functions

void _setFieldBody (class FieldBody *aFieldBody)
 Sets the field body.


Constructor & Destructor Documentation

Field  ) 
 

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

Field const Field other  ) 
 

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

Parameters:
other Field instance to copy

Field const String str,
Node parent = 0
 

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

~Field  )  [virtual]
 

Destructor


Member Function Documentation

FieldBody * _createFieldBody const String fieldName,
const String fieldBody,
Node parent
[static]
 

This static member function is the default factory function for creating FieldBody instances. For a full discussion, see createFieldBody().

void _setFieldBody class FieldBody fieldBody  )  [protected]
 

Sets the FieldBody object contained by this object. This function differs from setFieldBody() in that it does not set the is-modified flag.

Parameters:
fieldBody field body object

void assemble  )  [virtual]
 

This virtual function, inherited from Node, executes the assemble operation for Field objects. The assemble operation creates or updates the string representation from the broken-down representation. For Field objects, the assemble operation builds the string representation from the field name and the string representation of the contained FieldBody object. Before it builds the string representation, this function calls the assemble() member function of its contained FieldBody object.

You should call this member function after you set or modify either the field name or the contained FieldBody object, and before you retrieve the string representation.

This function clears the is-modified flag.

Implements Node.

Node * clone  )  const [virtual]
 

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

Returns:
a copy of this object

Implements Node.

FieldBody * createFieldBody const String fieldName,
const String fieldBody,
Node parent
[static]
 

The parse() member function calls createFieldBody() to create an instance of a subclass of FieldBody. createFieldBody() examines the field name and creates a subclass of FieldBody that is appropriate for that field.

You may create subclasses of some library classes. To make the library create instances of those subclasses, you must install a factory function, using the Field::sCreateFieldBody hook. If sCreateFieldBody is not NULL, then createFieldBody() calls the function it points to. Otherwise, createFieldBody() calls the default factory function _createFieldBody().

Parameters:
fieldName field name
fieldBody field body
parent parent node of the FieldBody object
Returns:
an instance of a subclass of FieldBody

FieldBody & fieldBody  )  const
 

Gets the field body.

Returns:
a reference to the contained FieldBody object

const String & fieldName  )  const
 

Gets the field name.

Returns:
the field name

Field * newField  )  [static]
 

Creates a new Field object.

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

Returns:
new Field instance
See also:
sNewField

const Field & operator= const Field other  ) 
 

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

Parameters:
other Field instance to copy

void parse  )  [virtual]
 

This virtual function, inherited from Node, executes the parse operation for Field objects. The parse operation creates or updates the broken-down representation from the string representation. For Field objects, the parse operation updates the value of the field name string and creates an instance of the appropriate subclass of FieldBody. This member function also calls the parse() member function of the FieldBody object it creates.

You should call this member function after you set or modify the string representation, and before you access the field name or field body.

This function clears the is-modified flag.

Implements Node.

void setFieldBody class FieldBody fieldBody  ) 
 

Sets the field body.

Parameters:
fieldBody the field body object

void setFieldName const String name  ) 
 

Sets the field name.

Parameters:
name the field name


Member Data Documentation

FieldBody *(* sCreateFieldBody)(const String &, const String &, Node *)=0 [static]
 

This function pointer points to a user-supplied factory function for creating FieldBody instances. For a full discussion, see createFieldBody().

Field *(* sNewField)()=0 [static]
 

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

See also:
newField()

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