Qpid Proton C++  0.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
url.hpp
1 #ifndef URL_HPP
2 #define URL_HPP
3 
4 /*
5  * Licensed to the Apache Software Foundation (ASF) under one
6  * or more contributor license agreements. See the NOTICE file
7  * distributed with this work for additional information
8  * regarding copyright ownership. The ASF licenses this file
9  * to you under the Apache License, Version 2.0 (the
10  * "License"); you may not use this file except in compliance
11  * with the License. You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing,
16  * software distributed under the License is distributed on an
17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  * KIND, either express or implied. See the License for the
19  * specific language governing permissions and limitations
20  * under the License.
21  */
22 
23 #include "proton/types.hpp"
24 #include "proton/error.hpp"
25 
26 #include <iosfwd>
27 
28 struct pn_url_t;
29 
30 namespace proton {
31 
33 struct url_error : public error {
35  PN_CPP_EXTERN explicit url_error(const std::string&);
37 };
38 
51 class url {
52  public:
53  static const std::string AMQP;
54  static const std::string AMQPS;
55 
57  PN_CPP_EXTERN url();
58 
66  PN_CPP_EXTERN url(const std::string& url_str, bool defaults=true);
67 
75  PN_CPP_EXTERN url(const char* url_str, bool defaults=true);
76 
78  PN_CPP_EXTERN url(const url&);
79  PN_CPP_EXTERN ~url();
81  PN_CPP_EXTERN url& operator=(const url&);
82 
86  PN_CPP_EXTERN void parse(const std::string&);
87 
91  PN_CPP_EXTERN void parse(const char*);
92 
94  PN_CPP_EXTERN bool empty() const;
95 
97  PN_CPP_EXTERN std::string str() const;
98 
102 
103  PN_CPP_EXTERN std::string scheme() const;
104  PN_CPP_EXTERN void scheme(const std::string&);
105 
107  PN_CPP_EXTERN std::string username() const;
108  PN_CPP_EXTERN void username(const std::string&);
110 
111  PN_CPP_EXTERN std::string password() const;
112  PN_CPP_EXTERN void password(const std::string&);
113 
114  PN_CPP_EXTERN std::string host() const;
115  PN_CPP_EXTERN void host(const std::string&);
117  PN_CPP_EXTERN void port(const std::string&);
118  PN_CPP_EXTERN std::string port() const;
120  PN_CPP_EXTERN uint16_t port_int() const;
122  PN_CPP_EXTERN std::string host_port() const;
123 
125  PN_CPP_EXTERN std::string path() const;
126  PN_CPP_EXTERN void path(const std::string&);
127 
129 
133  PN_CPP_EXTERN void defaults();
135 
136  private:
137  pn_url_t* url_;
138 
140 
141  friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const url&);
142 
148  friend PN_CPP_EXTERN std::istream& operator>>(std::istream&, url&);
149 
151 };
152 
153 }
154 
155 #endif // URL_HPP
std::string path() const
path is everything after the final &quot;/&quot;.
std::string str() const
str returns the URL as a string
static const std::string AMQP
&quot;amqp&quot; prefix
Definition: url.hpp:53
std::string host_port() const
host_port returns just the host:port part of the URL
url & operator=(const url &)
Copy a URL.
Raised if URL parsing fails.
Definition: url.hpp:33
url()
Create an empty URL.
Defines C++ types representing AMQP types.
void parse(const std::string &)
Parse a string as a URL.
bool empty() const
True if the URL is empty.
A proton URL.
Definition: url.hpp:51
void port(const std::string &)
port can be a number or a symbolic name such as &quot;amqp&quot;.
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:54