Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
00001 #ifndef QPID_URL_H 00002 #define QPID_URL_H 00003 00004 /* 00005 * 00006 * Copyright (c) 2006 The Apache Software Foundation 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 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 #include "qpid/CommonImportExport.h" 00029 00030 namespace qpid { 00031 00032 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a); 00033 00035 struct Url : public std::vector<Address> { 00036 00038 static Url getHostNameUrl(uint16_t port); 00039 00042 QPID_COMMON_EXTERN static Url getIpAddressesUrl(uint16_t port); 00043 00044 struct Invalid : public Exception { Invalid(const std::string& s); }; 00045 00047 QPID_COMMON_EXTERN std::string str() const; 00048 00050 Url() {} 00051 00053 explicit Url(const Address& addr) { push_back(addr); } 00054 00056 explicit Url(const std::string& url) { parse(url.c_str()); } 00057 00059 explicit Url(const char* url) { parse(url); } 00060 00061 Url& operator=(const Url& u) { this->std::vector<Address>::operator=(u); cache=u.cache; return *this; } 00062 Url& operator=(const char* s) { parse(s); return *this; } 00063 Url& operator=(const std::string& s) { parse(s); return *this; } 00064 00066 QPID_COMMON_EXTERN void throwIfEmpty() const; 00067 00072 QPID_COMMON_EXTERN void parse(const char* url); 00073 QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); } 00074 00079 void parseNoThrow(const char* url); 00080 00081 private: 00082 mutable std::string cache; // cache string form for efficiency. 00083 }; 00084 00085 inline bool operator==(const Url& a, const Url& b) { return a.str()==b.str(); } 00086 inline bool operator!=(const Url& a, const Url& b) { return a.str()!=b.str(); } 00087 00088 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Url& url); 00089 QPID_COMMON_EXTERN std::istream& operator>>(std::istream& is, Url& url); 00090 00091 } // namespace qpid 00092 00093 #endif