Qpid Proton C++  0.13.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
url.hpp
1 #ifndef PROTON_URL_HPP
2 #define PROTON_URL_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./types_fwd.hpp"
26 #include "./error.hpp"
27 
28 #include <iosfwd>
29 
30 struct pn_url_t;
31 
32 namespace proton {
33 
35 struct
36 PN_CPP_CLASS_EXTERN url_error : public error {
39  PN_CPP_EXTERN explicit url_error(const std::string&);
41 };
42 
55 class url {
56  public:
57  static const std::string AMQP;
58  static const std::string AMQPS;
59 
60  // XXX No constructor for an empty URL?
61  // XXX What is the default 'defaults' behavior?
62 
67  PN_CPP_EXTERN url(const std::string& url_str);
68 
78  PN_CPP_EXTERN url(const std::string& url_str, bool defaults);
80 
82  PN_CPP_EXTERN url(const url&);
83 
84  PN_CPP_EXTERN ~url();
85 
87  PN_CPP_EXTERN url& operator=(const url&);
88 
90  PN_CPP_EXTERN bool empty() const;
91 
93  PN_CPP_EXTERN operator std::string() const;
94 
98 
100  PN_CPP_EXTERN std::string scheme() const;
102  PN_CPP_EXTERN std::string user() const;
103  // XXX Passwords in URLs are dumb.
105  PN_CPP_EXTERN std::string password() const;
107  PN_CPP_EXTERN std::string host() const;
109  PN_CPP_EXTERN std::string port() const;
111  PN_CPP_EXTERN uint16_t port_int() const;
113  PN_CPP_EXTERN std::string host_port() const;
114 
115  // XXX is this not confusing (or incorrect)? The path starts with
116  // the first / after //.
118  PN_CPP_EXTERN std::string path() const;
119 
121 
122  private:
123  pn_url_t* url_;
124 
126 
127  friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const url&);
128 
129  // XXX Why is it important to have this?
135  friend PN_CPP_EXTERN std::istream& operator>>(std::istream&, url&);
136 
138 };
139 
140 } // proton
141 
142 #endif // PROTON_URL_HPP
std::string path() const
path is everything after the final &quot;/&quot;.
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.
static const std::string AMQP
&quot;amqp&quot; prefix
Definition: url.hpp:57
std::string host_port() const
host_port returns just the host:port part of the URL
std::string port() const
port can be a number or a symbolic name such as &quot;amqp&quot;.
url & operator=(const url &)
Copy a URL.
An error encountered during URL parsing.
Definition: url.hpp:35
std::string scheme() const
amqp or amqps.
url(const std::string &url_str)
Parse url_str as an AMQP URL.
bool empty() const
True if the URL is empty.
std::string password() const
The password.
A Proton URL.
Definition: url.hpp:55
std::string user() const
The user name for authentication.
Forward declarations for all the C++ types used by Proton to represent AMQP types.
std::string host() const
The host name or IP address.
The base Proton error.
Definition: error.hpp:37
uint16_t port_int() const
port_int is the numeric value of the port.
static const std::string AMQPS
&quot;amqps&quot; prefix
Definition: url.hpp:58