VMime
headerFieldFactory Class Reference

#include <headerFieldFactory.hpp>

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< headerFieldFactorygetInstance ()

Protected Types

typedef shared_ptr< headerField >(* AllocFunc) (void)
typedef std::map< string, AllocFuncNameMap
typedef std::map< string, ValueInfoValueMap

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

◆ AllocFunc

typedef shared_ptr< headerField >(* AllocFunc) (void)
protected

◆ NameMap

typedef std::map<string, AllocFunc> NameMap
protected

◆ ValueMap

typedef std::map<string, ValueInfo> ValueMap
protected

Constructor & Destructor Documentation

◆ headerFieldFactory()

◆ ~headerFieldFactory()

~headerFieldFactory ( )
protected

Member Function Documentation

◆ create()

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 createValue(), m_nameMap, vmime::NULL_STRING, and stringUtils::toLower().

◆ createValue()

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 m_valueMap, and stringUtils::toLower().

Referenced by create().

◆ getInstance()

◆ isValueTypeValid()

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(), m_valueMap, and stringUtils::toLower().

◆ registerField()

template<class T>
void registerField ( const string & name)

Register a field type.

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

References m_nameMap, and stringUtils::toLower().

Referenced by headerFieldFactory().

◆ registerFieldValue()

template<class T>
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, m_valueMap, and stringUtils::toLower().

Referenced by headerFieldFactory().

Member Data Documentation

◆ m_nameMap

NameMap m_nameMap
protected

Referenced by create(), and registerField().

◆ m_valueMap

ValueMap m_valueMap
protected

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