VMime
header Class Reference
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
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< 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 ( )

Member Function Documentation

void appendField ( shared_ptr< headerField field)

Add a field at the end of the list.

Parameters
fieldfield to append

Referenced by header::getField().

shared_ptr<const headerField> Bcc ( ) const
shared_ptr<headerField> Bcc ( )
shared_ptr<const headerField> Cc ( ) const
shared_ptr<headerField> Cc ( )
shared_ptr< component > clone ( ) const
virtual

Clone this component.

Returns
a copy of this component

Implements component.

References vmime::clone().

shared_ptr<const headerField> ContentDescription ( ) const
shared_ptr<headerField> ContentDescription ( )
shared_ptr<headerField> ContentDisposition ( )
shared_ptr<const headerField> ContentDisposition ( ) const
shared_ptr<headerField> ContentId ( )
shared_ptr<const headerField> ContentId ( ) const
shared_ptr<headerField> ContentLocation ( )
shared_ptr<const headerField> ContentLocation ( ) const
shared_ptr<headerField> ContentTransferEncoding ( )
shared_ptr<const headerField> ContentTransferEncoding ( ) const
shared_ptr<headerField> ContentType ( )
shared_ptr<const headerField> ContentType ( ) const
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().

Referenced by header::operator=().

shared_ptr<headerField> Date ( )
shared_ptr<const headerField> Date ( ) const
shared_ptr<headerField> DeliveredTo ( )
shared_ptr<const headerField> DeliveredTo ( ) const
shared_ptr<headerField> Disposition ( )
shared_ptr<const headerField> Disposition ( ) const
shared_ptr<headerField> DispositionNotificationTo ( )
shared_ptr<const headerField> DispositionNotificationTo ( ) const
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 header::removeAllFields().

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

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
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
shared_ptr<const headerField> From ( ) const
shared_ptr<headerField> From ( )
void generateImpl ( const generationContext ctx,
utility::outputStream os,
const size_t  curLinePos = 0,
size_t newLinePos = NULL 
) const
protectedvirtual

Implements component.

References vmime::CRLF.

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

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

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
const shared_ptr< headerField > getFieldAt ( const size_t  pos)

Return the field at the specified position.

Parameters
posposition
Returns
field at position 'pos'
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'
size_t getFieldCount ( ) const

Return the number of fields in the list.

Returns
number of fields
const std::vector< shared_ptr< const headerField > > getFieldList ( ) const

Return the field list.

Returns
list of fields
const std::vector< shared_ptr< headerField > > getFieldList ( )

Return the field list.

Returns
list of fields
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().

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

shared_ptr<const headerField> InReplyTo ( ) const
shared_ptr<headerField> InReplyTo ( )
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
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
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 header::replaceField().

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
bool isEmpty ( ) const

Tests whether the list of fields is empty.

Returns
true if there is no field, false otherwise
shared_ptr<headerField> MessageId ( )
shared_ptr<const headerField> MessageId ( ) const
shared_ptr<const headerField> MimeVersion ( ) const
shared_ptr<headerField> MimeVersion ( )
header & operator= ( const header other)

References header::copyFrom().

shared_ptr<headerField> Organization ( )
shared_ptr<const headerField> Organization ( ) const
shared_ptr<headerField> OriginalMessageId ( )
shared_ptr<const headerField> OriginalMessageId ( ) const
void parseImpl ( const parsingContext ctx,
const string buffer,
const size_t  position,
const size_t  end,
size_t newPosition = NULL 
)
protectedvirtual

Reimplemented from component.

References headerField::parseNext().

shared_ptr<const headerField> References ( ) const
shared_ptr<headerField> References ( )
void removeAllFields ( )

Remove all fields from the list.

Referenced by header::~header().

void removeAllFields ( const string fieldName)

Remove all fields with the specified name.

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

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 header::removeAllFields(), and header::replaceField().

void removeField ( const size_t  pos)

Remove the field at the specified position.

Parameters
posposition of the field to remove
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 header::insertFieldBefore(), and header::removeField().

shared_ptr<headerField> ReplyTo ( )
shared_ptr<const headerField> ReplyTo ( ) const
shared_ptr<headerField> ReturnPath ( )
shared_ptr<const headerField> ReturnPath ( ) const
shared_ptr<headerField> Sender ( )
shared_ptr<const headerField> Sender ( ) const
shared_ptr<const headerField> Subject ( ) const
shared_ptr<headerField> Subject ( )
shared_ptr<const headerField> To ( ) const
shared_ptr<headerField> To ( )
shared_ptr<const headerField> UserAgent ( ) const
shared_ptr<headerField> UserAgent ( )

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