1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org> 2 3 #ifndef ADDRESS_H 4 #define ADDRESS_H 5 6 #include "estring.h" 7 #include "list.h" 8 9 10 class UString; 11 12 13 class Address 14 : public Garbage 15 { 16 public: 17 Address(); 18 Address( const UString &, const EString &, const EString & ); 19 Address( const UString &, const UString &, const UString & ); 20 Address( const Address & ); 21 22 Address &operator=( const Address & ); 23 24 enum Type { Normal, Bounce, EmptyGroup, Local, Invalid }; 25 Type type() const; 26 27 uint id() const; 28 void setId( uint ); 29 30 EString name( bool ) const; 31 UString uname() const; 32 UString localpart() const; 33 UString domain() const; 34 35 EString lpdomain() const; 36 EString toString( bool ) const; 37 valid()38 bool valid() const { return type() != Invalid; } 39 40 static void uniquify( List<Address> * ); 41 42 bool localpartIsSensible() const; 43 44 void clone( const Address & ); 45 46 void setError( const EString & ); 47 EString error() const; 48 49 bool needsUnicode() const; 50 51 private: 52 class AddressData * d; 53 54 void init( const UString &, const UString &, const UString & ); 55 }; 56 57 58 class AddressParser 59 : public Garbage 60 { 61 public: 62 AddressParser( EString ); 63 64 EString error() const; 65 List<Address> * addresses() const; 66 67 void assertSingleAddress(); 68 69 static AddressParser * references( const EString & ); 70 71 private: 72 void address( int & ); 73 void space( int & ); 74 void comment( int & ); 75 void ccontent( int & ); 76 UString domain( int & ); 77 UString phrase( int & ); 78 UString localpart( int & ); 79 UString atom( int & ); 80 static EString unqp( const EString & ); 81 void route( int & ); 82 int findBorder( int, int ); 83 84 void error( const char *, int ); 85 86 void add( UString, const UString &, const UString & ); 87 void add( const UString &, const UString & ); 88 89 class AddressParserData * d; 90 }; 91 92 93 #endif 94