it_bus/url.h

00001 #ifndef _IT_BUS_URL_H_
00002 #define _IT_BUS_URL_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/types.h>
00008 #include <it_dsa/hash_map.h>
00009 #include <it_dsa/string_builder.h>
00010 
00011 #ifndef IT_IOSTREAMS_FREE
00012 #include <it_cal/iostream.h>
00013 #endif
00014 
00015 namespace IT_Bus
00016 {
00017     class URLImpl;
00018 
00019     class IT_AFC_API MalformedURLException :
00020         public Exception
00021     {
00022       public:
00023         MalformedURLException(
00024             String message
00025         );
00026 
00030         virtual Exception*
00031         clone() const;
00032     
00036         virtual void
00037         rethrow() const;
00038     };
00039     
00040     class IT_AFC_API URL
00041     {
00042       public:
00046         URL();
00047         
00051         URL(
00052             const URL&      rhs
00053         );
00054 
00097         URL(
00098             const String&   url
00099         ) throw((MalformedURLException));
00100 
00104         URL(
00105             const URL&      context,
00106             const String&   location
00107         ) throw((MalformedURLException));
00108 
00112         URL(
00113             const String&   protocol,
00114             const String&   protocol_data
00115         ) throw((MalformedURLException));
00116 
00117         /*
00118          *  Constructor from protocol and data for use by internet URL only
00119          *
00120          *  URL("protocol", "host", port, "path")
00121          *  path must begin with a forward slash
00122          */
00123         URL(
00124             const String&   protocol,
00125             const String&   host,
00126             unsigned int    port,
00127             const String&   path
00128         ) throw((MalformedURLException));
00129 
00130         ~URL();
00131 
00132         URL& 
00133         operator=(
00134             const URL&      rhs
00135         ) throw(());
00136 
00137         Boolean operator==(
00138             const URL&      rhs
00139         ) const throw(());
00140 
00141         Boolean operator!=(
00142             const URL&      rhs
00143         ) const throw(());
00144 
00148         String
00149         get_host() const;
00150 
00154         String
00155         get_path() const;
00156 
00161         int
00162         get_port() const;
00163 
00164         String
00165         get_protocol() const;
00166 
00167         String
00168         get_protocol_data() const;
00169 
00170         String
00171         to_string() const;
00172 
00173         size_t hash() const;
00174 
00178         bool
00179         is_file() const;
00180 
00181       private:
00182         URLImpl*    m_impl;
00183     };
00184 
00185 
00186     struct IT_AFC_API URLHash
00187     {
00188         size_t
00189         operator()(
00190             const URL& to_hash
00191         )
00192         {
00193             return to_hash.hash();
00194         }
00195     };
00196 
00197 
00198     struct IT_AFC_API URLEq
00199     {
00200         Boolean
00201         operator()(
00202             const URL& a,
00203             const URL& b
00204         ) 
00205         {
00206             return a == b;
00207         }
00208     };
00209 
00210     template <class T>
00211     class URLMap : public IT_HashMap<URL, T, URLHash, URLEq>
00212     {
00213         // Complete.
00214     };
00215 }
00216 
00217 #ifndef IT_IOSTREAMS_FREE
00218 inline IT_ostream&
00219 operator<< (
00220     IT_ostream&         os,
00221     const IT_Bus::URL&  url
00222 )
00223 {
00224     return os << (const IT_String&)url.to_string();
00225 }
00226 #endif
00227 
00228 inline IT_StringBuilder&
00229 operator<< (
00230     IT_StringBuilder&   s,
00231     const IT_Bus::URL&  url
00232 )
00233 {
00234     return s << (const IT_String&)url.to_string();
00235 }
00236 
00237 #endif  

Generated on Tue Mar 20 15:27:44 2007 for Artix by  doxygen 1.5.1-p1