24 #include <servus/types.h>
31 namespace detail {
class URI; }
62 typedef std::map< std::string, std::string > KVMap;
63 typedef KVMap::const_iterator ConstKVIter;
73 SERVUS_API
explicit URI(
const std::string& uri );
76 SERVUS_API
explicit URI(
const char* uri );
79 SERVUS_API
URI(
const URI& from );
87 SERVUS_API
bool operator == (
const URI& rhs )
const;
90 SERVUS_API
bool operator != (
const URI& rhs )
const;
94 SERVUS_API
const std::string& getScheme()
const;
95 SERVUS_API
const std::string& getUserinfo()
const;
96 SERVUS_API uint16_t getPort()
const;
97 SERVUS_API
const std::string& getHost()
const;
103 SERVUS_API
const std::string& getPath()
const;
104 SERVUS_API
const std::string& getQuery()
const;
105 SERVUS_API
const std::string& getFragment()
const;
110 SERVUS_API
void setScheme(
const std::string& scheme );
111 SERVUS_API
void setUserInfo(
const std::string& userinfo );
112 SERVUS_API
void setHost(
const std::string& host );
113 SERVUS_API
void setPort( uint16_t port );
114 SERVUS_API
void setPath(
const std::string& path );
115 SERVUS_API
void setQuery(
const std::string& query );
116 SERVUS_API
void setFragment(
const std::string& fragment );
129 SERVUS_API ConstKVIter
queryEnd()
const;
134 SERVUS_API ConstKVIter
findQuery(
const std::string& key )
const;
137 SERVUS_API
void addQuery(
const std::string& key,
138 const std::string& value );
142 detail::URI*
const _impl;
145 inline std::ostream& operator << ( std::ostream& os,
const URI& uri )
147 if( !uri.getScheme().empty( ))
148 os << uri.getScheme() <<
"://";
151 if( !uri.getHost().empty( ))
153 if( !uri.getUserinfo().empty( ))
154 os << uri.getUserinfo() <<
"@";
157 os <<
':' << uri.getPort();
160 if( !uri.getQuery().empty( ))
161 os <<
'?' << uri.getQuery();
162 if( !uri.getFragment().empty( ))
163 os <<
'#' << uri.getFragment();
170 inline std::string to_string(
const servus::URI& uri )
177 #endif // SERVUS_URI_H
void addQuery(const std::string &key, const std::string &value)
Add a key-value pair to the query.
The URI class parses the given uri using the generic syntax from RFC3986 and RFC6570.
Defines export visibility macros for library Servus.
URI & operator=(const URI &rhs)
Assign the data from another URI.
bool operator==(const URI &rhs) const
Equals operator.
ConstKVIter queryEnd() const
ConstKVIter queryBegin() const
ConstKVIter findQuery(const std::string &key) const
URI()
Construct an empty URI.
bool operator!=(const URI &rhs) const
Not equals operator.
std::string getAuthority() const
Return the compound authority part of the URI.