Main Page Class Hierarchy Alphabetical List Compound List Examples |
00001 /*************************************************************************** 00002 copyright : (C) 2002-2005 by Stefano Barbato 00003 email : [email protected] 00004 00005 $Id: mailbox_8h-source.html,v 1.4 2006-03-12 12:28:31 tat Exp $ 00006 ***************************************************************************/ 00007 00008 /*************************************************************************** 00009 * * 00010 * This program is free software; you can redistribute it and/or modify * 00011 * it under the terms of the GNU General Public License as published by * 00012 * the Free Software Foundation; either version 2 of the License, or * 00013 * (at your option) any later version. * 00014 * * 00015 ***************************************************************************/ 00016 #ifndef _MIMETIC_RFC822_MAILBOX_H_ 00017 #define _MIMETIC_RFC822_MAILBOX_H_ 00018 #include <string> 00019 #include <mimetic/rfc822/fieldvalue.h> 00020 namespace mimetic 00021 { 00022 00023 00024 00025 /// Represents a \e mailbox email address as defined in the RFC822 00026 /** 00027 Use this class if you want to build or parse email addresses. Each email address 00028 as defined by RFC822 have a mailbox std::string, a domain name, a sourceroute and 00029 a label. Note that just mailbox and domain are mandatory. 00030 Mailboxes can be represented in different ways, can contain rfc822 comments and 00031 blank spaces, can be double-quoted and contain source route. Please read the 00032 RFC822 for details. 00033 00034 Parsing: 00035 \code 00036 Mailbox mbx("Mario (Spider)Rossi <@[email protected]:[email protected]>"); 00037 cout << mbx.mailbox() << endl; 00038 cout << mbx.domain() << endl; 00039 cout << mbx.label() << endl; 00040 cout << mbx.sourceroute() << endl; 00041 cout << mbx.text() << endl; 00042 \endcode 00043 00044 Building: 00045 \code 00046 Mailbox mbx; 00047 mbx.mailbox("mrossi"); 00048 mbx.domain("dom.it"); 00049 mbx.label("Mario (Spider)Rossi"); 00050 mbx.sourceroute("@[email protected]"); 00051 \endcode 00052 00053 \sa <a href="../RFC/rfc822.txt">RFC822</a> 00054 */ 00055 struct Mailbox: public FieldValue 00056 { 00057 Mailbox(); 00058 Mailbox(const char*); 00059 Mailbox(const std::string&); 00060 void mailbox(const std::string&); 00061 void domain(const std::string&); 00062 void label(const std::string&); 00063 void sourceroute(const std::string&); 00064 std::string mailbox(int bCanonical = 1) const; 00065 std::string domain(int bCanonical = 1) const; 00066 std::string label(int bCanonical = 0) const; 00067 std::string sourceroute(int bCanonical = 1) const; 00068 bool operator==(const Mailbox&) const; 00069 bool operator!=(const Mailbox&) const; 00070 void set(const std::string&); 00071 std::string str() const; 00072 protected: 00073 FieldValue* clone() const; 00074 private: 00075 std::string m_mailbox, m_domain, m_label, m_route; 00076 }; 00077 00078 00079 } 00080 00081 #endif