VMime
header Class Reference

#include <header.hpp>

Inheritance diagram for header:
Collaboration diagram for header:

Public Member Functions

 header ()
 ~header ()
shared_ptr< headerFieldFrom ()
shared_ptr< const headerFieldFrom () const
shared_ptr< headerFieldSender ()
shared_ptr< const headerFieldSender () const
shared_ptr< headerFieldReplyTo ()
shared_ptr< const headerFieldReplyTo () const
shared_ptr< headerFieldDeliveredTo ()
shared_ptr< const headerFieldDeliveredTo () const
shared_ptr< headerFieldInReplyTo ()
shared_ptr< const headerFieldInReplyTo () const
shared_ptr< headerFieldReturnPath ()
shared_ptr< const headerFieldReturnPath () const
shared_ptr< headerFieldReferences ()
shared_ptr< const headerFieldReferences () const
shared_ptr< headerFieldTo ()
shared_ptr< const headerFieldTo () const
shared_ptr< headerFieldCc ()
shared_ptr< const headerFieldCc () const
shared_ptr< headerFieldBcc ()
shared_ptr< const headerFieldBcc () const
shared_ptr< headerFieldDate ()
shared_ptr< const headerFieldDate () const
shared_ptr< headerFieldSubject ()
shared_ptr< const headerFieldSubject () const
shared_ptr< headerFieldOrganization ()
shared_ptr< const headerFieldOrganization () const
shared_ptr< headerFieldUserAgent ()
shared_ptr< const headerFieldUserAgent () const
shared_ptr< headerFieldContentType ()
shared_ptr< const headerFieldContentType () const
shared_ptr< headerFieldContentDescription ()
shared_ptr< const headerFieldContentDescription () const
shared_ptr< headerFieldContentTransferEncoding ()
shared_ptr< const headerFieldContentTransferEncoding () const
shared_ptr< headerFieldMimeVersion ()
shared_ptr< const headerFieldMimeVersion () const
shared_ptr< headerFieldContentDisposition ()
shared_ptr< const headerFieldContentDisposition () const
shared_ptr< headerFieldContentId ()
shared_ptr< const headerFieldContentId () const
shared_ptr< headerFieldMessageId ()
shared_ptr< const headerFieldMessageId () const
shared_ptr< headerFieldContentLocation ()
shared_ptr< const headerFieldContentLocation () const
shared_ptr< headerFieldOriginalMessageId ()
shared_ptr< const headerFieldOriginalMessageId () const
shared_ptr< headerFieldDisposition ()
shared_ptr< const headerFieldDisposition () const
shared_ptr< headerFieldDispositionNotificationTo ()
shared_ptr< const headerFieldDispositionNotificationTo () const
bool hasField (const string &fieldName) const
shared_ptr< headerFieldfindField (const string &fieldName) const
template<typename T>
shared_ptr< T > findField (const string &fieldName) const
template<typename T>
shared_ptr< T > findFieldValue (const string &fieldName) const
std::vector< shared_ptr< headerField > > findAllFields (const string &fieldName)
shared_ptr< headerFieldgetField (const string &fieldName)
template<typename T>
shared_ptr< T > getField (const string &fieldName)
void appendField (shared_ptr< headerField > field)
void insertFieldBefore (shared_ptr< headerField > beforeField, shared_ptr< headerField > field)
void insertFieldBefore (const size_t pos, shared_ptr< headerField > field)
void insertFieldAfter (shared_ptr< headerField > afterField, shared_ptr< headerField > field)
void insertFieldAfter (const size_t pos, shared_ptr< headerField > field)
void removeField (shared_ptr< headerField > field)
void removeField (const size_t pos)
void replaceField (shared_ptr< headerField > field, shared_ptr< headerField > newField)
void removeAllFields ()
void removeAllFields (const string &fieldName)
size_t getFieldCount () const
bool isEmpty () const
const shared_ptr< headerFieldgetFieldAt (const size_t pos)
const shared_ptr< const headerFieldgetFieldAt (const size_t pos) const
const std::vector< shared_ptr< const headerField > > getFieldList () const
const std::vector< shared_ptr< headerField > > getFieldList ()
shared_ptr< componentclone () const
void copyFrom (const component &other)
headeroperator= (const header &other)
const std::vector< shared_ptr< component > > getChildComponents ()
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

Protected Member Functions

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

Detailed Description

Header section of a MIME part.

Constructor & Destructor Documentation

◆ header()

header ( )

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

◆ ~header()

~header ( )

References removeAllFields().

Member Function Documentation

◆ appendField()

void appendField ( shared_ptr< headerField > field)

Add a field at the end of the list.

Parameters
fieldfield to append

Referenced by getField().

◆ Bcc() [1/2]

shared_ptr< headerField > Bcc ( )

References Bcc(), and FIELD_ACCESS.

Referenced by Bcc().

◆ Bcc() [2/2]

shared_ptr< const headerField > Bcc ( ) const

◆ Cc() [1/2]

shared_ptr< headerField > Cc ( )

References Cc(), and FIELD_ACCESS.

Referenced by Cc().

◆ Cc() [2/2]

shared_ptr< const headerField > Cc ( ) const

◆ clone()

shared_ptr< component > clone ( ) const
virtual

Clone this component.

Returns
a copy of this component

Implements component.

References vmime::clone().

◆ ContentDescription() [1/2]

shared_ptr< headerField > ContentDescription ( )

References ContentDescription(), and FIELD_ACCESS.

Referenced by ContentDescription().

◆ ContentDescription() [2/2]

shared_ptr< const headerField > ContentDescription ( ) const

◆ ContentDisposition() [1/2]

shared_ptr< headerField > ContentDisposition ( )

References ContentDisposition(), and FIELD_ACCESS.

Referenced by ContentDisposition().

◆ ContentDisposition() [2/2]

shared_ptr< const headerField > ContentDisposition ( ) const

◆ ContentId() [1/2]

shared_ptr< headerField > ContentId ( )

References ContentId(), and FIELD_ACCESS.

Referenced by ContentId().

◆ ContentId() [2/2]

shared_ptr< const headerField > ContentId ( ) const

◆ ContentLocation() [1/2]

shared_ptr< headerField > ContentLocation ( )

References ContentLocation(), and FIELD_ACCESS.

Referenced by ContentLocation().

◆ ContentLocation() [2/2]

shared_ptr< const headerField > ContentLocation ( ) const

◆ ContentTransferEncoding() [1/2]

shared_ptr< headerField > ContentTransferEncoding ( )

◆ ContentTransferEncoding() [2/2]

shared_ptr< const headerField > ContentTransferEncoding ( ) const

◆ ContentType() [1/2]

shared_ptr< headerField > ContentType ( )

References ContentType(), and FIELD_ACCESS.

Referenced by ContentType().

◆ ContentType() [2/2]

shared_ptr< const headerField > ContentType ( ) const

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

References vmime::clone(), component::component(), and header().

Referenced by operator=().

◆ Date() [1/2]

shared_ptr< headerField > Date ( )

References Date(), and FIELD_ACCESS.

Referenced by Date(), and transport::processHeader().

◆ Date() [2/2]

shared_ptr< const headerField > Date ( ) const

◆ DeliveredTo() [1/2]

shared_ptr< headerField > DeliveredTo ( )

References DeliveredTo(), and FIELD_ACCESS.

Referenced by DeliveredTo().

◆ DeliveredTo() [2/2]

shared_ptr< const headerField > DeliveredTo ( ) const

◆ Disposition() [1/2]

shared_ptr< headerField > Disposition ( )

References Disposition(), and FIELD_ACCESS.

Referenced by Disposition().

◆ Disposition() [2/2]

shared_ptr< const headerField > Disposition ( ) const

◆ DispositionNotificationTo() [1/2]

shared_ptr< headerField > DispositionNotificationTo ( )

◆ DispositionNotificationTo() [2/2]

shared_ptr< const headerField > DispositionNotificationTo ( ) const

◆ findAllFields()

std::vector< shared_ptr< headerField > > findAllFields ( const string & fieldName)

Find all fields that match the specified name.

If no field is found, an empty vector is returned.

Parameters
fieldNamename of field to return (eg: "X-Mailer" or "From", common field names are available in the vmime::fields namespace)
Returns
list of fields with the specified name

References stringUtils::toLower().

Referenced by removeAllFields().

◆ findField() [1/2]

template<typename T>
shared_ptr< T > findField ( const string & fieldName) const

Find the first field that matches the specified name, casted to the specified field type.

Field name is case-insensitive. If no field is found, or the field is not of the specified type, NULL is returned.

Parameters
fieldNamename of field whose value is to be returned (eg: "X-Mailer" or "From", common field names are available in the vmime::fields namespace)
Returns
first field with the specified name, or NULL if no field with this name was found

References findField().

◆ findField() [2/2]

shared_ptr< headerField > findField ( const string & fieldName) const

Find the first field that matches the specified name.

Field name is case-insensitive. If no field is found, NULL is returned.

Parameters
fieldNamename of field to return (eg: "X-Mailer" or "From", common field names are available in the vmime::fields namespace)
Returns
first field with the specified name, or NULL if no field with this name was found

References stringUtils::toLower().

Referenced by DispositionNotificationTo(), findField(), and findFieldValue().

◆ findFieldValue()

template<typename T>
shared_ptr< T > findFieldValue ( const string & fieldName) const

Find the value of the first field that matches the specified name, casted to the specified value type.

Field name is case-insensitive. If no field is found, or the field value is not of the specified type, NULL is returned.

Parameters
fieldNamename of field to return (eg: "X-Mailer" or "From", common field names are available in the vmime::fields namespace)
Returns
value of the first field with the specified name, or NULL if no field with this name was found, or the value is not of the specified type

References findField().

◆ From() [1/2]

shared_ptr< headerField > From ( )

References From().

Referenced by From().

◆ From() [2/2]

shared_ptr< const headerField > From ( ) const

◆ generateImpl()

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

Implements component.

References vmime::CRLF.

◆ getChildComponents()

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

Return the list of children of this component.

Returns
list of child components

Implements component.

References vmime::copy_vector().

◆ getField() [1/2]

template<typename T>
shared_ptr< T > getField ( const string & fieldName)

Find the first field that matches the specified name, casted to the specified type.

If no field is found, one will be created and inserted into the header.

Returns
first field with the specified name or a new field if no field is found

References getField().

◆ getField() [2/2]

shared_ptr< headerField > getField ( const string & fieldName)

Find the first field that matches the specified name.

If no field is found, one will be created and inserted into the header.

Parameters
fieldNamename of field to return (eg: "X-Mailer" or "From", common field names are available in the vmime::fields namespace)
Returns
first field with the specified name or a new field if no field is found

References appendField(), vmime::end(), headerFieldFactory::getInstance(), and stringUtils::toLower().

Referenced by getField().

◆ getFieldAt() [1/2]

const shared_ptr< headerField > getFieldAt ( const size_t pos)

Return the field at the specified position.

Parameters
posposition
Returns
field at position 'pos'

Referenced by transport::processHeader().

◆ getFieldAt() [2/2]

const shared_ptr< const headerField > getFieldAt ( const size_t pos) const

Return the field at the specified position.

Parameters
posposition
Returns
field at position 'pos'

◆ getFieldCount()

size_t getFieldCount ( ) const

Return the number of fields in the list.

Returns
number of fields

Referenced by transport::processHeader().

◆ getFieldList() [1/2]

const std::vector< shared_ptr< headerField > > getFieldList ( )

Return the field list.

Returns
list of fields

◆ getFieldList() [2/2]

const std::vector< shared_ptr< const headerField > > getFieldList ( ) const

Return the field list.

Returns
list of fields

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

References component::getGeneratedSize().

◆ hasField()

bool hasField ( const string & fieldName) const

Checks whether (at least) one field with this name exists.

Field name is case-insensitive.

Returns
true if at least one field with the specified name exists, or false otherwise

References stringUtils::toLower().

Referenced by DispositionNotificationTo(), and transport::processHeader().

◆ InReplyTo() [1/2]

shared_ptr< headerField > InReplyTo ( )

References FIELD_ACCESS, and InReplyTo().

Referenced by InReplyTo().

◆ InReplyTo() [2/2]

shared_ptr< const headerField > InReplyTo ( ) const

◆ insertFieldAfter() [1/2]

void insertFieldAfter ( const size_t pos,
shared_ptr< headerField > field )

Insert a new field after the specified position.

Parameters
posposition of the field before the new field
fieldfield to insert

◆ insertFieldAfter() [2/2]

void insertFieldAfter ( shared_ptr< headerField > afterField,
shared_ptr< headerField > field )

Insert a new field after the specified field.

Parameters
afterFieldfield after which the new field will be inserted
fieldfield to insert
Exceptions
exceptions::no_such_fieldif the field is not in the list

◆ insertFieldBefore() [1/2]

void insertFieldBefore ( const size_t pos,
shared_ptr< headerField > field )

Insert a new field before the specified position.

Parameters
posposition at which to insert the new field (0 to insert at the beginning of the list)
fieldfield to insert

◆ insertFieldBefore() [2/2]

void insertFieldBefore ( shared_ptr< headerField > beforeField,
shared_ptr< headerField > field )

Insert a new field before the specified field.

Parameters
beforeFieldfield before which the new field will be inserted
fieldfield to insert
Exceptions
exceptions::no_such_fieldif the field is not in the list

Referenced by replaceField().

◆ isEmpty()

bool isEmpty ( ) const

Tests whether the list of fields is empty.

Returns
true if there is no field, false otherwise

◆ MessageId() [1/2]

shared_ptr< headerField > MessageId ( )

References FIELD_ACCESS, and MessageId().

Referenced by MessageId(), and transport::processHeader().

◆ MessageId() [2/2]

shared_ptr< const headerField > MessageId ( ) const

◆ MimeVersion() [1/2]

shared_ptr< headerField > MimeVersion ( )

◆ MimeVersion() [2/2]

shared_ptr< const headerField > MimeVersion ( ) const

◆ operator=()

header & operator= ( const header & other)

References copyFrom(), and header().

◆ Organization() [1/2]

shared_ptr< headerField > Organization ( )

References FIELD_ACCESS, and Organization().

Referenced by Organization().

◆ Organization() [2/2]

shared_ptr< const headerField > Organization ( ) const

◆ OriginalMessageId() [1/2]

shared_ptr< headerField > OriginalMessageId ( )

References FIELD_ACCESS, and OriginalMessageId().

Referenced by OriginalMessageId().

◆ OriginalMessageId() [2/2]

shared_ptr< const headerField > OriginalMessageId ( ) const

◆ parseImpl()

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

◆ References() [1/2]

shared_ptr< headerField > References ( )

References FIELD_ACCESS, and References().

Referenced by References().

◆ References() [2/2]

shared_ptr< const headerField > References ( ) const

◆ removeAllFields() [1/2]

void removeAllFields ( )

Remove all fields from the list.

Referenced by parseImpl(), and ~header().

◆ removeAllFields() [2/2]

void removeAllFields ( const string & fieldName)

Remove all fields with the specified name.

References findAllFields(), and removeField().

◆ removeField() [1/2]

void removeField ( const size_t pos)

Remove the field at the specified position.

Parameters
posposition of the field to remove

◆ removeField() [2/2]

void removeField ( shared_ptr< headerField > field)

Remove the specified field from the list.

Parameters
fieldfield to remove
Exceptions
exceptions::no_such_fieldif the field is not in the list

Referenced by transport::processHeader(), removeAllFields(), and replaceField().

◆ replaceField()

void replaceField ( shared_ptr< headerField > field,
shared_ptr< headerField > newField )

Replaces a field with another field.

Parameters
fieldfield to be replaced
newFieldfield to replace with
Exceptions
exceptions::no_such_fieldif the field is not in the list

References insertFieldBefore(), and removeField().

Referenced by transport::processHeader().

◆ ReplyTo() [1/2]

shared_ptr< headerField > ReplyTo ( )

References FIELD_ACCESS, and ReplyTo().

Referenced by ReplyTo().

◆ ReplyTo() [2/2]

shared_ptr< const headerField > ReplyTo ( ) const

◆ ReturnPath() [1/2]

shared_ptr< headerField > ReturnPath ( )

References FIELD_ACCESS, and ReturnPath().

Referenced by ReturnPath().

◆ ReturnPath() [2/2]

shared_ptr< const headerField > ReturnPath ( ) const

◆ Sender() [1/2]

shared_ptr< headerField > Sender ( )

References FIELD_ACCESS, and Sender().

Referenced by Sender().

◆ Sender() [2/2]

shared_ptr< const headerField > Sender ( ) const

◆ Subject() [1/2]

shared_ptr< headerField > Subject ( )

References FIELD_ACCESS, and Subject().

Referenced by Subject().

◆ Subject() [2/2]

shared_ptr< const headerField > Subject ( ) const

◆ To() [1/2]

shared_ptr< headerField > To ( )

References FIELD_ACCESS, and To().

Referenced by To().

◆ To() [2/2]

shared_ptr< const headerField > To ( ) const

◆ UserAgent() [1/2]

shared_ptr< headerField > UserAgent ( )

References FIELD_ACCESS, and UserAgent().

Referenced by UserAgent().

◆ UserAgent() [2/2]

shared_ptr< const headerField > UserAgent ( ) const

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