Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

passport.h

Go to the documentation of this file.
00001 #ifndef __msn_passport_h__
00002 #define __msn_passport_h__
00003 
00004 /*
00005  * passport.h
00006  * libmsn
00007  *
00008  * Created by Mark Rowe on Thu May 20 2004.
00009  * Copyright (c) 2004 Mark Rowe. All rights reserved.
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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

Generated on Sun Feb 6 19:59:40 2005 for libmsn by  doxygen 1.4.1