Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
qpid/Url.h
Go to the documentation of this file.
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 
00033 struct Url : public std::vector<Address> {
00034 
00035     struct Invalid : public Exception { QPID_COMMON_EXTERN Invalid(const std::string& s); };
00036 
00038     QPID_COMMON_EXTERN std::string str() const;
00039 
00041     Url() {}
00042 
00044     explicit Url(const Address& addr) { push_back(addr); }
00045 
00047     explicit Url(const std::string& url) { parse(url.c_str()); }
00049     explicit Url(const std::string& url, const std::string& defaultProtocol) { parse(url.c_str(), defaultProtocol); }
00050 
00052     explicit Url(const char* url) { parse(url); }
00053 
00054     Url& operator=(const char* s) { parse(s); return *this; }
00055     Url& operator=(const std::string& s) { parse(s); return *this; }
00056 
00058     QPID_COMMON_EXTERN void throwIfEmpty() const;
00059 
00063     QPID_COMMON_EXTERN void parse(const char* url);
00064     QPID_COMMON_EXTERN void parse(const char* url, const std::string& defaultProtocol);
00065     QPID_COMMON_INLINE_EXTERN void parse(const std::string& url) { parse(url.c_str()); }
00066 
00068     QPID_COMMON_EXTERN void parseNoThrow(const char* url);
00069     QPID_COMMON_EXTERN void parseNoThrow(const char* url, const std::string& defaultProtocol);
00070 
00074     QPID_COMMON_EXTERN static void addProtocol(const std::string& tag);
00075 
00076     QPID_COMMON_EXTERN void setUser(const std::string&);
00077     QPID_COMMON_EXTERN void setPass(const std::string&);
00078     QPID_COMMON_EXTERN std::string getUser() const;
00079     QPID_COMMON_EXTERN std::string getPass() const;
00080 
00081   private:
00082     mutable std::string cache;  // cache string form for efficiency.
00083     std::string user, pass;
00084 
00085   friend class UrlParser;
00086 };
00087 
00088 inline bool operator==(const Url& a, const Url& b) { return a.str()==b.str(); }
00089 inline bool operator!=(const Url& a, const Url& b) { return a.str()!=b.str(); }
00090 
00091 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Url& url);
00092 QPID_COMMON_EXTERN std::istream& operator>>(std::istream& is, Url& url);
00093 
00094 } // namespace qpid
00095 
00096 #endif  

Qpid C++ API Reference
Generated on Fri Aug 23 2013 for Qpid C++ Client API by doxygen 1.7.5