Qpid Proton C++ API  0.32.0
url.hpp
Go to the documentation of this file.
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 "./internal/pn_unique_ptr.hpp"
26 #include "./error.hpp"
27 
28 #include <proton/type_compat.h>
29 
30 #include <iosfwd>
31 #include <string>
32 
35 
36 namespace proton {
37 
41 
42 struct
43 PN_CPP_DEPRECATED("Use a third-party URL library")
44 PN_CPP_CLASS_EXTERN url_error : public error {
47  PN_CPP_EXTERN explicit url_error(const std::string&);
49 };
50 
65 class PN_CPP_DEPRECATED("Use a third-party URL library") url {
66  public:
67  static const std::string AMQP;
68  static const std::string AMQPS;
69 
70  // XXX No constructor for an empty URL?
71  // XXX What is the default 'defaults' behavior?
72 
77  PN_CPP_EXTERN url(const std::string& url_str);
78 
88  PN_CPP_EXTERN url(const std::string& url_str, bool defaults);
90 
92  PN_CPP_EXTERN url(const url&);
93 
94  PN_CPP_EXTERN ~url();
95 
97  PN_CPP_EXTERN url& operator=(const url&);
98 
100  PN_CPP_EXTERN bool empty() const;
101 
103  PN_CPP_EXTERN operator std::string() const;
104 
108 
110  PN_CPP_EXTERN std::string scheme() const;
112  PN_CPP_EXTERN std::string user() const;
113  // XXX Passwords in URLs are dumb.
115  PN_CPP_EXTERN std::string password() const;
117  PN_CPP_EXTERN std::string host() const;
119  PN_CPP_EXTERN std::string port() const;
121  PN_CPP_EXTERN uint16_t port_int() const;
123  PN_CPP_EXTERN std::string host_port() const;
124 
125  // XXX is this not confusing (or incorrect)? The path starts with
126  // the first / after //.
128  PN_CPP_EXTERN std::string path() const;
129 
131 
133  friend PN_CPP_EXTERN std::string to_string(const url&);
134 
135  private:
136  struct impl;
137  internal::pn_unique_ptr<impl> impl_;
138 
140 
141  friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const url&);
142 
143  // XXX Why is it important to have this?
149  friend PN_CPP_EXTERN std::istream& operator>>(std::istream&, url&);
150 
152 };
153 
154 } // proton
155 
156 #endif // PROTON_URL_HPP
proton::url::operator=
url & operator=(const url &)
Copy a URL.
proton::error
The base Proton error.
Definition: error.hpp:41
proton::url::url
url(const std::string &url_str)
Parse url_str as an AMQP URL.
proton::url::url
url(const url &)
Copy a URL.
proton::url::port
std::string port() const
port can be a number or a symbolic name such as "amqp".
proton::operator<<
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.
proton::url::password
std::string password() const
The password.
proton::operator>>
proton::codec::decoder & operator>>(proton::codec::decoder &d, map< K, T > &m)
Decode from a proton::map.
proton::url::to_string
friend std::string to_string(const url &)
Return URL as a string.
proton::url::empty
bool empty() const
True if the URL is empty.
proton::url::scheme
std::string scheme() const
amqp or amqps.
proton::url_error
Deprecated - Use a third-party URL library.
Definition: url.hpp:44
proton::url::host_port
std::string host_port() const
host_port returns just the host:port part of the URL
proton::url
Deprecated - Use a third-party URL library.
Definition: url.hpp:65
proton::url::AMQPS
static const std::string AMQPS
"amqps" prefix
Definition: url.hpp:68
proton::url::user
std::string user() const
The user name for authentication.
proton::url::host
std::string host() const
The host name or IP address.
proton
The main Proton namespace.
Definition: annotation_key.hpp:33
proton::url::port_int
uint16_t port_int() const
port_int is the numeric value of the port.
proton::url::path
std::string path() const
path is everything after the final "/".
proton::url::AMQP
static const std::string AMQP
"amqp" prefix
Definition: url.hpp:67
error.hpp
The base Proton error.