VMime
headerField Class Reference

#include <headerField.hpp>

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 headerFieldValuegetValue () const
template<typename T>
shared_ptr< const T > getValue () const
virtual shared_ptr< headerFieldValuegetValue ()
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() [1/2]

headerField ( )
protected

References m_name.

Referenced by copyFrom(), header, and operator=().

◆ headerField() [2/2]

headerField ( const string & fieldName)
protected

References m_name.

◆ ~headerField()

Member Function Documentation

◆ clone()

shared_ptr< component > clone ( ) const
virtual

Clone this component.

Returns
a copy of this component

Implements component.

References headerFieldFactory::getInstance(), and m_name.

Referenced by header.

◆ copyFrom()

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 component::component(), headerField(), and m_value.

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

◆ generateImpl()

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

Implements component.

Reimplemented in parameterizedHeaderField.

References m_name, and m_value.

Referenced by parameterizedHeaderField::generateImpl().

◆ getChildComponents()

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 m_value.

Referenced by parameterizedHeaderField::getChildComponents(), and header.

◆ getGeneratedSize()

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.

Reimplemented in parameterizedHeaderField.

References m_name, and m_value.

Referenced by parameterizedHeaderField::getGeneratedSize().

◆ getName()

const string getName ( ) const

Return the name of this field.

Returns
field name

References m_name.

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

◆ getValue() [1/4]

template<typename T>
shared_ptr< T > getValue ( )

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

Returns
value object

References m_value.

◆ getValue() [2/4]

shared_ptr< headerFieldValue > getValue ( )
virtual

Return the value object attached to this field.

Returns
value object

References m_value.

◆ getValue() [3/4]

template<typename T>
shared_ptr< const T > getValue ( ) const

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

Returns
value object

References m_value.

◆ getValue() [4/4]

shared_ptr< const headerFieldValue > getValue ( ) const
virtual

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

Returns
read-only value object

References m_value.

Referenced by header, MDNHelper::isMDN(), and parameterizedHeaderField::parseImpl().

◆ isCustom()

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 m_name.

Referenced by header.

◆ operator=()

headerField & operator= ( const headerField & other)

References copyFrom(), and headerField().

Referenced by header.

◆ parseImpl()

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.

References vmime::end(), and m_value.

◆ parseNext()

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

◆ setName()

void setName ( const string & name)

Sets the name of this field.

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

References m_name.

Referenced by header.

◆ setValue() [1/3]

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(), getName(), and m_value.

◆ setValue() [2/3]

void setValue ( const string & value)

Set the value of this field given a character string.

Parameters
valuevalue string to parse

References component::parse().

◆ setValue() [3/3]

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(), getName(), and m_value.

Referenced by body::setEncoding().

◆ setValueConst()

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(), getName(), and m_value.

Member Data Documentation

◆ m_name

◆ m_value


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