Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  
mailbox.h
00001 /***************************************************************************
00002     copyright            : (C) 2002-2008 by Stefano Barbato
00003     email                : stefano@codesink.org
00004 
00005     $Id: mailbox.h,v 1.14 2008-10-07 11:06:27 tat Exp $
00006  ***************************************************************************/
00007 #ifndef _MIMETIC_RFC822_MAILBOX_H_
00008 #define _MIMETIC_RFC822_MAILBOX_H_
00009 #include <string>
00010 #include <mimetic/rfc822/fieldvalue.h>
00011 namespace mimetic
00012 {
00013 
00014 
00015 
00016 /// Represents a \e mailbox email address as defined in the RFC822
00017 /**
00018     Use this class if you want to build or parse email addresses. Each email address
00019     as defined by RFC822 have a mailbox std::string, a domain name, a sourceroute and
00020     a label. Note that just mailbox and domain are mandatory.
00021     Mailboxes can be represented in different ways, can contain rfc822 comments and
00022     blank spaces, can be double-quoted and contain source route. Please read the
00023     RFC822 for details.
00024 
00025     Parsing:
00026     \code
00027     Mailbox mbx("Mario (Spider)Rossi <@free.it@move.it:mrossi@dom.it>");
00028     cout << mbx.mailbox() << endl;
00029     cout << mbx.domain() << endl;
00030     cout << mbx.label() << endl;
00031     cout << mbx.sourceroute() << endl;
00032     cout << mbx.text() << endl;
00033     \endcode
00034 
00035     Building:
00036     \code
00037     Mailbox mbx;
00038     mbx.mailbox("mrossi");
00039     mbx.domain("dom.it");
00040     mbx.label("Mario (Spider)Rossi");
00041     mbx.sourceroute("@free.it@move.it");
00042     \endcode
00043 
00044     \sa <a href="../RFC/rfc822.txt">RFC822</a>
00045  */
00046 struct Mailbox: public FieldValue
00047 {
00048     Mailbox();
00049     Mailbox(const char*);
00050     Mailbox(const std::string&);
00051     void mailbox(const std::string&);
00052     void domain(const std::string&);    
00053     void label(const std::string&);
00054     void sourceroute(const std::string&);
00055     std::string mailbox(int bCanonical = 1) const;
00056     std::string domain(int bCanonical = 1) const;    
00057     std::string label(int bCanonical = 0) const;
00058     std::string sourceroute(int bCanonical = 1) const;
00059     bool operator==(const Mailbox&) const;
00060     bool operator!=(const Mailbox&) const;
00061     void set(const std::string&);
00062     std::string str() const;
00063 protected:
00064     FieldValue* clone() const;
00065 private:
00066     std::string m_mailbox, m_domain, m_label, m_route;
00067 };
00068 
00069 
00070 }
00071 
00072 #endif