VMime
header Class Reference

#include <header.hpp>

Inheritance diagram for header:
Collaboration diagram for header:

Public Member Functions

 header ()
 
 ~header ()
 
shared_ptr< headerField > From ()
 
shared_ptr< const headerField > From () const
 
shared_ptr< headerField > Sender ()
 
shared_ptr< const headerField > Sender () const
 
shared_ptr< headerField > ReplyTo ()
 
shared_ptr< const headerField > ReplyTo () const
 
shared_ptr< headerField > DeliveredTo ()
 
shared_ptr< const headerField > DeliveredTo () const
 
shared_ptr< headerField > InReplyTo ()
 
shared_ptr< const headerField > InReplyTo () const
 
shared_ptr< headerField > ReturnPath ()
 
shared_ptr< const headerField > ReturnPath () const
 
shared_ptr< headerField > References ()
 
shared_ptr< const headerField > References () const
 
shared_ptr< headerField > To ()
 
shared_ptr< const headerField > To () const
 
shared_ptr< headerField > Cc ()
 
shared_ptr< const headerField > Cc () const
 
shared_ptr< headerField > Bcc ()
 
shared_ptr< const headerField > Bcc () const
 
shared_ptr< headerField > Date ()
 
shared_ptr< const headerField > Date () const
 
shared_ptr< headerField > Subject ()
 
shared_ptr< const headerField > Subject () const
 
shared_ptr< headerField > Organization ()
 
shared_ptr< const headerField > Organization () const
 
shared_ptr< headerField > UserAgent ()
 
shared_ptr< const headerField > UserAgent () const
 
shared_ptr< headerField > ContentType ()
 
shared_ptr< const headerField > ContentType () const
 
shared_ptr< headerField > ContentDescription ()
 
shared_ptr< const headerField > ContentDescription () const
 
shared_ptr< headerField > ContentTransferEncoding ()
 
shared_ptr< const headerField > ContentTransferEncoding () const
 
shared_ptr< headerField > MimeVersion ()
 
shared_ptr< const headerField > MimeVersion () const
 
shared_ptr< headerField > ContentDisposition ()
 
shared_ptr< const headerField > ContentDisposition () const
 
shared_ptr< headerField > ContentId ()
 
shared_ptr< const headerField > ContentId () const
 
shared_ptr< headerField > MessageId ()
 
shared_ptr< const headerField > MessageId () const
 
shared_ptr< headerField > ContentLocation ()
 
shared_ptr< const headerField > ContentLocation () const
 
shared_ptr< headerField > OriginalMessageId ()
 
shared_ptr< const headerField > OriginalMessageId () const
 
shared_ptr< headerField > Disposition ()
 
shared_ptr< const headerField > Disposition () const
 
shared_ptr< headerField > DispositionNotificationTo ()
 
shared_ptr< const headerField > DispositionNotificationTo () const
 
bool hasField (const string &fieldName) const
 
shared_ptr< headerField > findField (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< headerField > getField (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< headerField > getFieldAt (const size_t pos)
 
const shared_ptr< const headerField > getFieldAt (const size_t pos) const
 
const std::vector< shared_ptr< const headerField > > getFieldList () const
 
const std::vector< shared_ptr< headerField > > getFieldList ()
 
shared_ptr< component > clone () const
 
void copyFrom (const component &other)
 
header & operator= (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 &)
 
object & operator= (const object &)
 
virtual ~object ()
 

Detailed Description

Header section of a MIME part.

Constructor & Destructor Documentation

◆ header()

header ( )

◆ ~header()

Member Function Documentation

◆ appendField()

void appendField ( shared_ptr< headerField >  field)

Add a field at the end of the list.

Parameters
fieldfield to append

References vmime::dynamicCast().

Referenced by header::getField().

◆ Bcc() [1/2]

shared_ptr< headerField > Bcc ( )

◆ Bcc() [2/2]

shared_ptr< const headerField > Bcc ( ) const

◆ Cc() [1/2]

◆ 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(), and vmime::dynamicCast().

◆ ContentDescription() [1/2]

shared_ptr< headerField > ContentDescription ( )

◆ ContentDescription() [2/2]

shared_ptr< const headerField > ContentDescription ( ) const

◆ ContentDisposition() [1/2]

shared_ptr< headerField > ContentDisposition ( )

◆ ContentDisposition() [2/2]

shared_ptr< const headerField > ContentDisposition ( ) const

◆ ContentId() [1/2]

shared_ptr< headerField > ContentId ( )

◆ ContentId() [2/2]

shared_ptr< const headerField > ContentId ( ) const

◆ ContentLocation() [1/2]

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

◆ 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(), and vmime::dynamicCast().

Referenced by header::operator=().

◆ Date() [1/2]

◆ Date() [2/2]

shared_ptr< const headerField > Date ( ) const

◆ DeliveredTo() [1/2]

shared_ptr< headerField > DeliveredTo ( )

◆ DeliveredTo() [2/2]

shared_ptr< const headerField > DeliveredTo ( ) const

◆ Disposition() [1/2]

shared_ptr< headerField > 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 vmime::dynamicCast(), and stringUtils::toLower().

Referenced by header::removeAllFields().

◆ findField() [1/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 vmime::dynamicCast(), and stringUtils::toLower().

◆ findField() [2/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 vmime::dynamicCast().

◆ 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 vmime::dynamicCast().

◆ From() [1/2]

shared_ptr< headerField > 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, and vmime::dynamicCast().

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

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 header::appendField(), vmime::dynamicCast(), vmime::end(), headerFieldFactory::getInstance(), and stringUtils::toLower().

◆ getField() [2/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 vmime::dynamicCast().

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

References vmime::dynamicCast().

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'

References vmime::dynamicCast().

◆ 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

References vmime::dynamicCast().

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

Referenced by transport::processHeader().

◆ InReplyTo() [1/2]

shared_ptr< headerField > 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

References vmime::dynamicCast().

◆ 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

References vmime::dynamicCast().

◆ 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

References vmime::dynamicCast().

◆ 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

References vmime::dynamicCast().

Referenced by header::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 ( )

◆ 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 header::copyFrom().

◆ Organization() [1/2]

shared_ptr< headerField > Organization ( )

◆ Organization() [2/2]

shared_ptr< const headerField > Organization ( ) const

◆ OriginalMessageId() [1/2]

shared_ptr< headerField > 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() [2/2]

shared_ptr< const headerField > References ( ) const

◆ removeAllFields() [1/2]

void removeAllFields ( )

Remove all fields from the list.

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

◆ removeAllFields() [2/2]

void removeAllFields ( const string &  fieldName)

Remove all fields with the specified name.

References vmime::dynamicCast(), header::findAllFields(), and header::removeField().

◆ removeField() [1/2]

void removeField ( const size_t  pos)

Remove the field at the specified position.

Parameters
posposition of the field to remove

References vmime::dynamicCast().

◆ 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

References vmime::dynamicCast().

Referenced by transport::processHeader(), header::removeAllFields(), and header::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 vmime::dynamicCast(), header::insertFieldBefore(), and header::removeField().

Referenced by transport::processHeader().

◆ ReplyTo() [1/2]

shared_ptr< headerField > ReplyTo ( )

◆ ReplyTo() [2/2]

shared_ptr< const headerField > ReplyTo ( ) const

◆ ReturnPath() [1/2]

shared_ptr< headerField > ReturnPath ( )

◆ ReturnPath() [2/2]

shared_ptr< const headerField > ReturnPath ( ) const

◆ Sender() [1/2]

shared_ptr< headerField > Sender ( )

◆ Sender() [2/2]

shared_ptr< const headerField > Sender ( ) const

◆ Subject() [1/2]

shared_ptr< headerField > Subject ( )

◆ Subject() [2/2]

shared_ptr< const headerField > Subject ( ) const

◆ To() [1/2]

◆ To() [2/2]

shared_ptr< const headerField > To ( ) const

◆ UserAgent() [1/2]

shared_ptr< headerField > UserAgent ( )

◆ UserAgent() [2/2]

shared_ptr< const headerField > UserAgent ( ) const

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