Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  
mailbox.h
1 /***************************************************************************
2  copyright : (C) 2002-2008 by Stefano Barbato
3  email : stefano@codesink.org
4 
5  $Id: mailbox.h,v 1.14 2008-10-07 11:06:27 tat Exp $
6  ***************************************************************************/
7 #ifndef _MIMETIC_RFC822_MAILBOX_H_
8 #define _MIMETIC_RFC822_MAILBOX_H_
9 #include <string>
10 #include <mimetic/rfc822/fieldvalue.h>
11 namespace mimetic
12 {
13 
14 
15 
16 /// Represents a \e mailbox email address as defined in the RFC822
17 /**
18  Use this class if you want to build or parse email addresses. Each email address
19  as defined by RFC822 have a mailbox std::string, a domain name, a sourceroute and
20  a label. Note that just mailbox and domain are mandatory.
21  Mailboxes can be represented in different ways, can contain rfc822 comments and
22  blank spaces, can be double-quoted and contain source route. Please read the
23  RFC822 for details.
24 
25  Parsing:
26  \code
27  Mailbox mbx("Mario (Spider)Rossi <@free.it@move.it:mrossi@dom.it>");
28  cout << mbx.mailbox() << endl;
29  cout << mbx.domain() << endl;
30  cout << mbx.label() << endl;
31  cout << mbx.sourceroute() << endl;
32  cout << mbx.text() << endl;
33  \endcode
34 
35  Building:
36  \code
37  Mailbox mbx;
38  mbx.mailbox("mrossi");
39  mbx.domain("dom.it");
40  mbx.label("Mario (Spider)Rossi");
41  mbx.sourceroute("@free.it@move.it");
42  \endcode
43 
44  \sa <a href="../RFC/rfc822.txt">RFC822</a>
45  */
46 struct Mailbox: public FieldValue
47 {
48  Mailbox();
49  Mailbox(const char*);
50  Mailbox(const std::string&);
51  void mailbox(const std::string&);
52  void domain(const std::string&);
53  void label(const std::string&);
54  void sourceroute(const std::string&);
55  std::string mailbox(int bCanonical = 1) const;
56  std::string domain(int bCanonical = 1) const;
57  std::string label(int bCanonical = 0) const;
58  std::string sourceroute(int bCanonical = 1) const;
59  bool operator==(const Mailbox&) const;
60  bool operator!=(const Mailbox&) const;
61  void set(const std::string&);
62  std::string str() const;
63 protected:
64  FieldValue* clone() const;
65 private:
66  std::string m_mailbox, m_domain, m_label, m_route;
67 };
68 
69 
70 }
71 
72 #endif
Represents a mailbox email address as defined in the RFC822.
Definition: mailbox.h:46
Value of an header field (base class)
Definition: fieldvalue.h:17