VMime
headerField Class Reference
Inheritance diagram for headerField:
Collaboration diagram for headerField:

Public Member Functions

 ~headerField ()
 
shared_ptr< componentclone () const
 
void copyFrom (const component &other)
 
headerFieldoperator= (const headerField &other)
 
const std::vector< shared_ptr
< component > > 
getChildComponents ()
 
void setName (const string &name)
 
const string getName () const
 
bool isCustom () const
 
virtual shared_ptr< const
headerFieldValue
getValue () const
 
template<typename T >
shared_ptr< const T > getValue () const
 
virtual shared_ptr
< headerFieldValue
getValue ()
 
template<typename T >
shared_ptr< T > getValue ()
 
virtual void setValue (shared_ptr< headerFieldValue > value)
 
virtual void setValueConst (shared_ptr< const headerFieldValue > value)
 
virtual void setValue (const headerFieldValue &value)
 
void setValue (const string &value)
 
size_t getGeneratedSize (const generationContext &ctx)
 
- Public Member Functions inherited from component
 component ()
 
virtual ~component ()
 
void parse (const string &buffer)
 
void parse (const parsingContext &ctx, const string &buffer)
 
void parse (shared_ptr< utility::inputStream > inputStream, const size_t length)
 
void parse (const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void parse (const parsingContext &ctx, const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void parse (shared_ptr< utility::inputStream > inputStream, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void parse (const parsingContext &ctx, shared_ptr< utility::inputStream > inputStream, const size_t position, const size_t end, size_t *newPosition=NULL)
 
virtual const string generate (const size_t maxLineLength=lineLengthLimits::infinite, const size_t curLinePos=0) const
 
virtual void generate (utility::outputStream &outputStream, const size_t curLinePos=0, size_t *newLinePos=NULL) const
 
virtual void generate (const generationContext &ctx, utility::outputStream &outputStream, const size_t curLinePos=0, size_t *newLinePos=NULL) const
 
size_t getParsedOffset () const
 
size_t getParsedLength () const
 

Static Public Member Functions

static shared_ptr< headerFieldparseNext (const parsingContext &ctx, const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 

Protected Member Functions

 headerField ()
 
 headerField (const string &fieldName)
 
void parseImpl (const parsingContext &ctx, const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void generateImpl (const generationContext &ctx, utility::outputStream &os, const size_t curLinePos=0, size_t *newLinePos=NULL) const
 
- Protected Member Functions inherited from component
void setParsedBounds (const size_t start, const size_t end)
 
virtual void parseImpl (const parsingContext &ctx, shared_ptr< utility::parserInputStreamAdapter > parser, const size_t position, const size_t end, size_t *newPosition=NULL)
 
- Protected Member Functions inherited from object
 object ()
 
 object (const object &)
 
objectoperator= (const object &)
 
virtual ~object ()
 

Protected Attributes

string m_name
 
shared_ptr< headerFieldValuem_value
 

Detailed Description

Base class for header fields.

Constructor & Destructor Documentation

headerField ( )
protected
headerField ( const string fieldName)
protected

Member Function Documentation

shared_ptr< component > clone ( ) const
virtual

Clone this component.

Returns
a copy of this component

Implements component.

References headerFieldFactory::getInstance(), and headerField::m_name.

void copyFrom ( const component other)
virtual

Replace data in this component by data in other component.

Both components must be of the same type.

Exceptions
std::bad_cast_exceptionif the components are not of the same (dynamic) type
Parameters
otherother component to copy data from

Implements component.

Reimplemented in parameterizedHeaderField.

References headerField::m_value.

Referenced by parameterizedHeaderField::copyFrom(), and headerField::operator=().

void generateImpl ( const generationContext ctx,
utility::outputStream os,
const size_t  curLinePos = 0,
size_t newLinePos = NULL 
) const
protectedvirtual

Implements component.

Reimplemented in parameterizedHeaderField.

Referenced by parameterizedHeaderField::generateImpl().

const std::vector< shared_ptr< component > > getChildComponents ( )
virtual

Return the list of children of this component.

Returns
list of child components

Implements component.

Reimplemented in parameterizedHeaderField.

References headerField::m_value.

Referenced by parameterizedHeaderField::getChildComponents().

size_t getGeneratedSize ( const generationContext ctx)
virtual

Get the number of bytes that will be used by this component when it is generated.

This may be a heuristically-derived estimate, but such an estimated size should always be larger than the actual generated size.

Parameters
ctxgeneration context
Returns
component size when generated

Reimplemented from component.

References headerField::m_name, and headerField::m_value.

const string getName ( ) const

Return the name of this field.

Returns
field name

References headerField::m_name.

Referenced by headerFieldFactory::isValueTypeValid(), headerField::setValue(), and headerField::setValueConst().

shared_ptr< const headerFieldValue > getValue ( ) const
virtual

Return the read-only value object attached to this field.

Returns
read-only value object

References headerField::m_value.

Referenced by body::getContentType(), and MDNHelper::isMDN().

shared_ptr<const T> getValue ( ) const

Return the read-only value object attached to this field, casted to the specified type.

Returns
value object
shared_ptr< headerFieldValue > getValue ( )
virtual

Return the value object attached to this field.

Returns
value object

References headerField::m_value.

shared_ptr<T> getValue ( )

Return the value object attached to this field, casted to the specified type.

Returns
value object
bool isCustom ( ) const

Check whether this field is a custom (non-standard) field.

Custom fields have a name beginning with "X-".

Returns
true if the field is a custom field, false otherwise

References headerField::m_name.

headerField & operator= ( const headerField other)
void parseImpl ( const parsingContext ctx,
const string buffer,
const size_t  position,
const size_t  end,
size_t newPosition = NULL 
)
protectedvirtual

Reimplemented from component.

Reimplemented in parameterizedHeaderField.

shared_ptr< headerField > parseNext ( const parsingContext ctx,
const string buffer,
const size_t  position,
const size_t  end,
size_t newPosition = NULL 
)
static

Parse a header field from a buffer.

Parameters
ctxparsing context
bufferinput buffer
positioncurrent position in the input buffer
endend position in the input buffer
newPositionwill receive the new position in the input buffer
Returns
parsed header field, or NULL if no more header field can be parsed in the input buffer

References vmime::end(), parserHelpers::findEOL(), headerFieldFactory::getInstance(), and parserHelpers::isSpace().

Referenced by header::parseImpl().

void setName ( const string name)

Sets the name of this field.

Parameters
namefield name (eg: "From" or "X-MyField").

References headerField::m_name.

void setValue ( shared_ptr< headerFieldValue value)
virtual

Set the value of this field.

Exceptions
exceptions::bad_field_value_typeif the value type is not valid for this header field
Parameters
valuenew value

References headerFieldFactory::getInstance(), headerField::getName(), and headerField::m_value.

void setValue ( const headerFieldValue value)
virtual

Set the value of this field (reference version).

The value will be cloned.

Exceptions
exceptions::bad_field_value_typeif the value type is not valid for this header field
Parameters
valuenew value

References vmime::clone(), headerFieldFactory::getInstance(), headerField::getName(), and headerField::m_value.

void setValue ( const string value)

Set the value of this field given a character string.

Parameters
valuevalue string to parse

References component::parse().

void setValueConst ( shared_ptr< const headerFieldValue value)
virtual

Set the value of this field by cloning the specified value.

Exceptions
exceptions::bad_field_value_typeif the value type is not valid for this header field
Parameters
valuenew value

References vmime::clone(), headerFieldFactory::getInstance(), headerField::getName(), and headerField::m_value.

Member Data Documentation


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