libmsn: /home/salem/libmsn/tags/libmsn-4.2/msn/passport.h Source File

libmsn 4.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

/home/salem/libmsn/tags/libmsn-4.2/msn/passport.h

    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  * Refactored by Tiago Salem Herrmann on 08/2007.
    00010  * Copyright (c) 2004 Mark Rowe. All rights reserved.
    00011  * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved
    00012  *
    00013  * This program is free software; you can redistribute it and/or modify
    00014  * it under the terms of the GNU General Public License as published by
    00015  * the Free Software Foundation; either version 2 of the License, or
    00016  * (at your option) any later version.
    00017  *
    00018  * This program is distributed in the hope that it will be useful,
    00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00021  * GNU General Public License for more details.
    00022  *
    00023  * You should have received a copy of the GNU General Public License
    00024  * along with this program; if not, write to the Free Software
    00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00026  */
    00027
    00028 #include <string>
    00029 #include <stdexcept>
    00030 #include <iostream>
    00031
    00032 #include "libmsn_export.h"
    00033
    00034 namespace MSN
    00035 {
    00040     class InvalidPassport : public std::runtime_error
    00041     {
    00042 public:
    00043         InvalidPassport(std::string err) : std::runtime_error(err) {};
    00044     };
    00045
    00052     class LIBMSN_EXPORT Passport
    00053     {
    00054 public:
    00055         Passport(std::string email_) : email(email_) { validate(); };
    00056         Passport(const char *email_) : email(std::string(email_)) { validate(); };
    00057         Passport() : email("") {};
    00058
    00059         operator std::string() const;
    00060         const char *c_str() const;
    00061         bool operator ==(const Passport & other) const { return this->email == other.email; };
    00062
    00063         friend bool operator ==(const Passport & p, const std::string & other) { return p.email == other; };
    00064         friend bool operator ==(const std::string & other, const Passport & p) { return p.email == other; };
    00065         friend std::istream& operator >>(std::istream & is, Passport & p) { is >> p.email; p.validate(); return is; }
    00066         friend std::ostream& operator <<(std::ostream & os, Passport & p) { os << p.email; p.validate(); return os; }
    00067 private:
    00068         void validate();
    00069         std::string email;
    00070     };
    00071 }
    00072
    00073 std::ostream & operator << (std::ostream & os, const MSN::Passport& passport);
    00074 #endif

All Classes Namespaces Functions Variables Enumerations Enumerator