Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

purl.h

Go to the documentation of this file.
00001 /*
00002  *   P::Classes - Portable C++ Application Framework
00003  *   Copyright (C) 2000-2002  Christian Prochnow <cproch@seculogix.de>
00004  *
00005  *   This library is free software; you can redistribute it and/or
00006  *   modify it under the terms of the GNU Lesser General Public
00007  *   License as published by the Free Software Foundation; either
00008  *   version 2 of the License, or (at your option) any later version.
00009  *
00010  *   This library is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *   Lesser General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU Lesser General Public
00016  *   License along with this library; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef _purl_h_
00021 #define _purl_h_
00022 
00023 #include <pclasses/pexport.h>
00024 #include <pclasses/pexception.h>
00025 #include <pclasses/pnetdb.h>
00026 #include <iostream>
00027 #include <string>
00028 
00029 namespace P {
00030 
00032 
00036 class PNET_EXPORT InvalidURL: public RuntimeError {
00037   public:
00038     inline InvalidURL(const char* _what, const SourceInfo& _si) throw()
00039       : RuntimeError(_what,_si) {}
00040 };
00041 
00043 
00051 class PNET_EXPORT URL {
00052   public:
00054 
00057     URL();
00058     
00060     URL(const std::string& url) throw(InvalidURL,NetDbError);
00061     
00062     URL(const URL& url);
00063     
00064     ~URL();
00065 
00066     inline const std::string& protocol() const
00067     { return m_proto; }
00068 
00069     void setProtocol(const std::string& proto, bool setPort = true);
00070     
00071     inline const std::string& host() const
00072     { return m_host; }
00073 
00074     void setHost(const std::string& host);
00075 
00076     inline const std::string& user() const
00077     { return m_user; }
00078 
00079     void setUser(const std::string& user);
00080 
00081     inline const std::string& password() const
00082     { return m_passwd; }
00083 
00084     void setPassword(const std::string& passwd);
00085                         
00086     inline unsigned short port() const
00087     { return m_port; }
00088 
00089     void setPort(unsigned short port);
00090     
00091     inline const std::string& path() const
00092     { return m_path; }
00093 
00094     void setPath(const std::string& path);
00095 
00096     URL& operator=(const URL& url);
00097     URL& operator=(const std::string& url) throw(InvalidURL,NetDbError);
00098 
00099     bool operator==(const URL& url) const;
00100     
00101     std::string str() const;
00102     
00103     PNET_EXPORT friend std::ostream& operator<<(std::ostream& os, const URL& url);
00104     PNET_EXPORT friend std::istream& operator>>(std::istream& is, URL& url) throw(InvalidURL);
00105             
00106   private:
00107     static unsigned short lookupPort(const std::string& service, const std::string& proto = "tcp");
00108     
00109     std::string    m_proto;
00110     std::string    m_host;
00111     std::string    m_user;
00112     std::string    m_passwd;
00113     unsigned short m_port;
00114     std::string    m_path;
00115 };
00116 
00117 }
00118 
00119 #endif

Generated on Fri Mar 12 21:08:31 2004 for P::Classes by doxygen 1.3.3