00001 #ifndef __msn_passport_h__
00002 #define __msn_passport_h__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <string>
00027 #include <stdexcept>
00028 #include <iostream>
00029
00030 namespace MSN
00031 {
00036 class InvalidPassport : public std::runtime_error
00037 {
00038 public:
00039 InvalidPassport(std::string err) : std::runtime_error(err) {};
00040 };
00041
00048 class Passport
00049 {
00050 public:
00051 Passport(std::string email_) : email(email_) { validate(); };
00052 Passport(const char *email_) : email(std::string(email_)) { validate(); };
00053 Passport() : email("") {};
00054
00055 operator std::string() const;
00056 const char *c_str() const;
00057 bool operator ==(const Passport & other) const { return this->email == other.email; };
00058
00059 friend bool operator ==(const Passport & p, const std::string & other) { return p.email == other; };
00060 friend bool operator ==(const std::string & other, const Passport & p) { return p.email == other; };
00061 friend std::istream& operator >>(std::istream & is, Passport & p) { is >> p.email; p.validate(); return is; }
00062 private:
00063 ;
00064 void validate();
00065 std::string email;
00066 };
00067 }
00068
00069 std::ostream & operator << (std::ostream & os, const MSN::Passport& passport);
00070 #endif