00001 #ifndef QPID_URL_H
00002 #define QPID_URL_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "qpid/Address.h"
00023 #include "qpid/Exception.h"
00024 #include <string>
00025 #include <vector>
00026 #include <new>
00027 #include <ostream>
00028
00029 namespace qpid {
00030
00031 std::ostream& operator<<(std::ostream& os, const TcpAddress& a);
00032
00034 struct Url : public std::vector<Address> {
00035
00037 static Url getHostNameUrl(uint16_t port);
00038
00041 static Url getIpAddressesUrl(uint16_t port);
00042
00043 struct InvalidUrl : public Exception {
00044 InvalidUrl(const std::string& s) : Exception(s) {}
00045 };
00046
00048 std::string str() const;
00049
00051 Url() {}
00052
00054 explicit Url(const Address& addr) { push_back(addr); }
00055
00057 explicit Url(const std::string& url) { parse(url.c_str()); }
00058
00060 explicit Url(const char* url) { parse(url); }
00061
00062 Url& operator=(const Url& u) { this->std::vector<Address>::operator=(u); cache=u.cache; return *this; }
00063 Url& operator=(const char* s) { parse(s); return *this; }
00064 Url& operator=(const std::string& s) { parse(s); return *this; }
00065
00067 void throwIfEmpty() const;
00068
00073 void parse(const char* url);
00074 void parse(const std::string& url) { parse(url.c_str()); }
00075
00080 void parseNoThrow(const char* url);
00081
00082 private:
00083 mutable std::string cache;
00084 };
00085
00086 inline bool operator==(const Url& a, const Url& b) { return a.str()==b.str(); }
00087 inline bool operator!=(const Url& a, const Url& b) { return a.str()!=b.str(); }
00088
00089 std::ostream& operator<<(std::ostream& os, const Url& url);
00090 std::istream& operator>>(std::istream& is, Url& url);
00091
00092 }
00093
00094 #endif