Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

rfc822::header Class Reference

a parsed header. More...

#include <header.h>

List of all members.

Public Methods

 header ()
 c'tor. More...

 header (const string &h)
 copy c'tor. More...

 header (const header &h)
 copy c'tor. More...

 header (const msg &h)
 creation from a message. More...

header & operator= (const header &h)
 assignment operator. More...

header & operator= (const string &h)
 set the eader. More...

const stringoperator[] (const string &id) const
 returns the specified header entry. More...

entry operator[] (const string &name)

Friends

class header::entry
class parser
ostream & operator<< (ostream &, const header &)


Detailed Description

a parsed header.

The header class contains a parsed header, which enables fast access to individual header entries.

One can access entries via the [] operators. Even values are defined that do not match exactly one entry. For example, the "from.email" entry will contain the email address from the "From: " header field.

Values like a "from.email" value are handled by certain specialized parsers, that are able to extract relevant information off a header entry and convert it into a format which is easy to handle. For example, "from.email" contains the email address of the "From: " header line, and "date.unix" contains the # of seconds since epoch of the "Date: " header field.

However, these entry parsers must be instantiated before parsing. A set of parsers is defined in the src/header.cpp source file. approbiate entry

See also:
parser.
Usage:
//
// load mbox file...
rfc822::mbox mails(*argv);

//
// ...and iterate over all messages
for(rfc822::mbox::iterator it = mails.begin();
        it != mails.end(); ++it)
        {
                rfc822::header& h = it->header;
                cout << "From " << '\"' <<  h["from"] << '\"' << endl;
                cout << "\t\"" <<  h["from.realname"] << '\"' << endl;
                cout << "\t\"" <<  h["from.email"] << '\"' << endl;
        }


Constructor & Destructor Documentation

rfc822::header::header   [inline]
 

c'tor.

rfc822::header::header const string   h [inline]
 

copy c'tor.

rfc822::header::header const header &    h [inline]
 

copy c'tor.

rfc822::header::header const msg   h
 

creation from a message.


Member Function Documentation

header& rfc822::header::operator= const string   h
 

set the eader.

When the text is set (this usually occurs behind the curtain: You don't have to call that method) the text is parsed into its individual lines, and then stored under a key derived from the entries name.

Parameters:
header  The new header.

header& rfc822::header::operator= const header &    h [inline]
 

assignment operator.

entry rfc822::header::operator[] const string   name [inline]
 

const string& rfc822::header::operator[] const string   id const [inline]
 

returns the specified header entry.

Parameters:
name  the name of the entry. Some names have special meaning, like "from.realname", which refers to the realname of the "From:" header entry. A complete list can be queried via the header::specialEntries() static method.
Returns:
a reference to an empty string if no such entry exists, or the required string, if it exists.


Friends And Related Function Documentation

friend class header::entry [friend]
 

ostream& operator<< ostream &   ,
const header &   
[friend]
 

friend class parser [friend]
 


The documentation for this class was generated from the following file:
Generated on Mon Oct 22 17:03:48 2001 for rfc822 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001