ZeroEQ  0.8.0
ZeroEQ - Zero Event Queue
uri.h
1 
2 /* Copyright (c) 2015, Human Brain Project
3  * Daniel.Nachbaur@epfl.ch
4  */
5 
6 #ifndef ZEROEQ_URI_H
7 #define ZEROEQ_URI_H
8 
9 #include <zeroeq/api.h>
10 
11 #include <servus/uri.h> // base class
12 
13 namespace zeroeq
14 {
19 class URI : private servus::URI
20 {
21 public:
23  ZEROEQ_API URI();
24 
25  ZEROEQ_API ~URI();
26 
27  ZEROEQ_API URI(const URI& from);
28 
30  ZEROEQ_API explicit URI(const std::string& uri);
31 
33  ZEROEQ_API explicit URI(const char* uri);
34 
36  ZEROEQ_API explicit URI(const servus::URI& from);
37 
38  ZEROEQ_API URI& operator=(const URI& rhs);
39 
40  /* Convert from servus::URI, set schema to "tcp" if empty */
41  ZEROEQ_API URI& operator=(const servus::URI& rhs);
42 
43  ZEROEQ_API bool operator==(const URI& rhs) const;
44 
45  ZEROEQ_API bool operator==(const servus::URI& rhs) const;
46 
47  ZEROEQ_API bool operator!=(const URI& rhs) const;
48 
49  ZEROEQ_API bool operator!=(const servus::URI& rhs) const;
50 
52  const servus::URI& toServusURI() const { return *this; }
55  using servus::URI::getScheme;
56  using servus::URI::getHost;
57  using servus::URI::getPort;
58  using servus::URI::getPath;
59  using servus::URI::getQuery;
60  using servus::URI::setHost;
61  using servus::URI::setPort;
63 };
64 
65 inline std::ostream& operator<<(std::ostream& os, const URI& uri)
66 {
67  return os << uri.toServusURI();
68 }
69 
70 } // namespace zeroeq
71 
72 namespace std
73 {
74 inline std::string to_string(const zeroeq::URI& uri)
75 {
76  return to_string(uri.toServusURI());
77 }
78 }
79 
80 #endif
Enhances servus::URI to guarantee the existance of a schema and to allow construction of [host][:port...
Definition: uri.h:19
Defines export visibility macros for library ZeroEQ.
STL namespace.
const servus::URI & toServusURI() const
Convert this URI to a servus::URI.
Definition: uri.h:52
URI()
Create a default URI in the form "tcp://".
Publish-subscribe classes for typed events.
Definition: broker.h:12