VMime
headerFieldFactory Class Reference

Classes

struct  ValueInfo
 

Public Member Functions

template<class T >
void registerField (const string &name)
 
template<class T >
void registerFieldValue (const string &name)
 
shared_ptr< headerFieldcreate (const string &name, const string &body=NULL_STRING)
 
shared_ptr< headerFieldValuecreateValue (const string &fieldName)
 
bool isValueTypeValid (const headerField &field, const headerFieldValue &value) const
 

Static Public Member Functions

static shared_ptr
< headerFieldFactory
getInstance ()
 

Protected Types

typedef shared_ptr< headerField >(* AllocFunc )(void)
 
typedef std::map< string,
AllocFunc
NameMap
 
typedef std::map< string,
ValueInfo
ValueMap
 

Protected Member Functions

 headerFieldFactory ()
 
 ~headerFieldFactory ()
 

Protected Attributes

NameMap m_nameMap
 
ValueMap m_valueMap
 

Detailed Description

Creates header field and header field value objects.

Member Typedef Documentation

typedef shared_ptr<headerField>(* AllocFunc)(void)
protected
typedef std::map<string, AllocFunc> NameMap
protected
typedef std::map<string, ValueInfo> ValueMap
protected

Constructor & Destructor Documentation

~headerFieldFactory ( )
protected

Member Function Documentation

shared_ptr< headerField > create ( const string name,
const string body = NULL_STRING 
)

Create a new field object for the specified field name.

If the field name has not been registered, a default type is used.

Parameters
namefield name
bodystring that will be parsed to initialize the value of the field
Returns
a new field object

References vmime::NULL_STRING, and stringUtils::toLower().

shared_ptr< headerFieldValue > createValue ( const string fieldName)

Create a new field value for the specified field.

Parameters
fieldNamename of the field for which to create value
Returns
a new value object for the field

References headerFieldFactory::m_valueMap, and stringUtils::toLower().

bool isValueTypeValid ( const headerField field,
const headerFieldValue value 
) const

Returns whether the specified value type is valid for the specified field.

Parameters
fieldheader field
valuevalue for this header field
Returns
true if the value type is compatible with the header field, or false otherwise

References headerField::getName(), and stringUtils::toLower().

void registerField ( const string name)

Register a field type.

Parameters
Tfield class (must inherit from 'headerField')
namefield name (eg. "X-MyField")

References stringUtils::toLower().

void registerFieldValue ( const string name)

Register a field value type.

Parameters
Tvalue class (must inherit from 'headerFieldValue')
namefield name

References headerFieldFactory::ValueInfo::allocFunc, headerFieldFactory::ValueInfo::checkTypeFunc, and stringUtils::toLower().

Member Data Documentation

NameMap m_nameMap
protected
ValueMap m_valueMap
protected

The documentation for this class was generated from the following files: