00001 #ifndef IONFLUX_TOOLS_EMAILADDRESS 00002 #define IONFLUX_TOOLS_EMAILADDRESS 00003 /* ========================================================================== 00004 * Ionflux Tools 00005 * Copyright (c) 2005 Joern P. Meier 00006 * mail@ionflux.org 00007 * -------------------------------------------------------------------------- 00008 * EMailAddress.hpp EMail address. 00009 * ========================================================================== 00010 * 00011 * This file is part of Ionflux Tools. 00012 * 00013 * Ionflux Tools is free software; you can redistribute it and/or modify it 00014 * under the terms of the GNU General Public License as published by the 00015 * Free Software Foundation; either version 2 of the License, or (at your 00016 * option) any later version. 00017 * 00018 * Ionflux Tools is distributed in the hope that it will be useful, but 00019 * WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 * General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along 00024 * with Ionflux Tools; if not, write to the Free Software Foundation, Inc., 00025 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 * 00027 * ========================================================================== */ 00028 00029 #include "ionflux/tools.hpp" 00030 #include "ionflux/ManagedObject.hpp" 00031 #include "ionflux/StringManipulator.hpp" 00032 00033 namespace Ionflux 00034 { 00035 00036 namespace Tools 00037 { 00038 00040 struct Mailbox 00041 { 00043 std::string displayName; 00045 std::string address; 00047 std::string localPart; 00049 std::string domain; 00050 }; 00051 00057 class EMailAddress 00058 : public Ionflux::Tools::ManagedObject 00059 { 00060 private: 00061 00062 protected: 00064 bool validAddress; 00066 std::vector<Mailbox> mailboxes; 00068 std::string rawAddress; 00070 std::string displayName; 00071 00072 public: 00074 static const Ionflux::Tools::TokenType TT_ATOM_TEXT; 00076 static const Ionflux::Tools::TokenType TT_SPECIAL; 00078 static const Ionflux::Tools::TokenType TT_FWS; 00079 00084 EMailAddress(); 00085 00092 EMailAddress(const EMailAddress& initAddress); 00093 00100 EMailAddress(const std::string& initRawAddress); 00101 00106 virtual ~EMailAddress(); 00107 00112 virtual void clear(); 00113 00122 virtual bool parse(const std::string& newRawAddress = ""); 00123 00130 virtual bool isValid() const; 00131 00138 virtual const std::vector<Mailbox>& getMailboxes() const; 00139 00146 virtual unsigned int getNumMailboxes() const; 00147 00157 virtual Mailbox getMailbox(unsigned int mailboxIndex = 0) const; 00158 00165 virtual EMailAddress& operator=(const EMailAddress& newEMailAddress); 00166 00173 virtual EMailAddress& operator=(const std::string& newRawAddress); 00174 00179 virtual void printDebugInfo() const; 00180 00187 virtual void setRawAddress(const std::string& newRawAddress); 00188 00195 virtual void setDisplayName(const std::string& newDisplayName); 00196 00201 virtual std::string getRawAddress() const; 00202 00207 virtual std::string getDisplayName() const; 00208 }; 00209 00210 } 00211 00212 } 00213 00217 #endif