24 #include <servus/types.h>
31 namespace detail {
class URI; }
58 typedef std::map< std::string, std::string > KVMap;
59 typedef KVMap::const_iterator ConstKVIter;
69 SERVUS_API
explicit URI(
const std::string& uri );
72 SERVUS_API
explicit URI(
const char* uri );
75 SERVUS_API
URI(
const URI& from );
83 SERVUS_API
bool operator == (
const URI& rhs )
const;
86 SERVUS_API
bool operator != (
const URI& rhs )
const;
90 SERVUS_API
const std::string& getScheme()
const;
91 SERVUS_API
const std::string& getUserinfo()
const;
92 SERVUS_API uint16_t getPort()
const;
93 SERVUS_API
const std::string& getHost()
const;
99 SERVUS_API
const std::string& getPath()
const;
100 SERVUS_API
const std::string& getQuery()
const;
101 SERVUS_API
const std::string& getFragment()
const;
106 SERVUS_API
void setScheme(
const std::string& scheme );
107 SERVUS_API
void setUserInfo(
const std::string& userinfo );
108 SERVUS_API
void setHost(
const std::string& host );
109 SERVUS_API
void setPort( uint16_t port );
110 SERVUS_API
void setPath(
const std::string& path );
111 SERVUS_API
void setFragment(
const std::string& fragment );
124 SERVUS_API ConstKVIter
queryEnd()
const;
129 SERVUS_API ConstKVIter
findQuery(
const std::string& key )
const;
132 SERVUS_API
void addQuery(
const std::string& key,
133 const std::string& value );
137 detail::URI*
const _impl;
140 inline std::ostream& operator << ( std::ostream& os,
const URI& uri )
142 if( !uri.getScheme().empty( ))
143 os << uri.getScheme() <<
"://";
146 if( !uri.getHost().empty( ))
148 if( !uri.getUserinfo().empty( ))
149 os << uri.getUserinfo() <<
"@";
152 os <<
':' << uri.getPort();
155 if( !uri.getQuery().empty( ))
156 os <<
'?' << uri.getQuery();
157 if( !uri.getFragment().empty( ))
158 os <<
'#' << uri.getFragment();
165 inline std::string to_string(
const servus::URI& uri )
172 #endif // SERVUS_URI_H
SERVUS_API URI & operator=(const URI &rhs)
Assign the data from another URI.
The URI class parses the given uri using the generic syntax from RFC3986.
SERVUS_API ConstKVIter queryBegin() const
Defines export visibility macros for Servus.
SERVUS_API bool operator==(const URI &rhs) const
Equals operator.
SERVUS_API bool operator!=(const URI &rhs) const
Not equals operator.
SERVUS_API std::string getAuthority() const
Return the compound authority part of the URI.
SERVUS_API ConstKVIter queryEnd() const
SERVUS_API void addQuery(const std::string &key, const std::string &value)
Add a key-value pair to the query.
SERVUS_API ConstKVIter findQuery(const std::string &key) const
SERVUS_API URI()
Construct an empty URI.