24 #include <servus/types.h>
30 namespace detail {
class URI; }
57 typedef std::map< std::string, std::string > KVMap;
58 typedef KVMap::const_iterator ConstKVIter;
68 SERVUS_API
explicit URI(
const std::string& uri );
71 SERVUS_API
explicit URI(
const char* uri );
74 SERVUS_API
URI(
const URI& from );
82 SERVUS_API
bool operator == (
const URI& rhs )
const;
85 SERVUS_API
bool operator != (
const URI& rhs )
const;
89 SERVUS_API
const std::string& getScheme()
const;
90 SERVUS_API
const std::string& getUserinfo()
const;
91 SERVUS_API uint16_t getPort()
const;
92 SERVUS_API
const std::string& getHost()
const;
93 SERVUS_API
const std::string& getPath()
const;
94 SERVUS_API
const std::string& getQuery()
const;
95 SERVUS_API
const std::string& getFragment()
const;
100 SERVUS_API
void setScheme(
const std::string& scheme );
101 SERVUS_API
void setHost(
const std::string& host );
102 SERVUS_API
void setPort( uint16_t port );
115 SERVUS_API ConstKVIter
queryEnd()
const;
120 SERVUS_API ConstKVIter
findQuery(
const std::string& key )
const;
123 SERVUS_API
void addQuery(
const std::string& key,
124 const std::string& value );
128 detail::URI*
const _impl;
131 inline std::ostream& operator << ( std::ostream& os,
const URI& uri )
133 if( !uri.getScheme().empty( ))
134 os << uri.getScheme() <<
"://";
135 if( !uri.getUserinfo().empty( ))
136 os << uri.getUserinfo() <<
"@";
139 os <<
':' << uri.getPort();
141 if( !uri.getQuery().empty( ))
142 os <<
'?' << uri.getQuery();
143 if( !uri.getFragment().empty( ))
144 os <<
'#' << uri.getFragment();
151 inline std::string to_string(
const servus::URI& uri )
158 #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 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.