20 #ifndef LUNCHBOX_URI_H
21 #define LUNCHBOX_URI_H
25 #include <boost/unordered_map.hpp>
26 #include <boost/lexical_cast.hpp>
30 namespace detail {
class URI; }
58 typedef boost::unordered_map< std::string, std::string > KVMap;
59 typedef KVMap::const_iterator ConstKVIter;
70 LUNCHBOX_API
explicit URI(
const std::string& uri );
73 LUNCHBOX_API
explicit URI(
const char* uri );
76 LUNCHBOX_API
URI(
const URI& from );
81 LUNCHBOX_API URI&
operator = (
const URI& rhs );
85 LUNCHBOX_API
const std::string& getScheme()
const;
86 LUNCHBOX_API
const std::string& getUserinfo()
const;
87 LUNCHBOX_API uint16_t getPort()
const;
88 LUNCHBOX_API
const std::string& getHost()
const;
89 LUNCHBOX_API
const std::string& getPath()
const;
90 LUNCHBOX_API
const std::string& getQuery()
const;
91 LUNCHBOX_API
const std::string& getFragment()
const;
106 LUNCHBOX_API ConstKVIter
queryEnd()
const;
112 LUNCHBOX_API ConstKVIter
findQuery(
const std::string& key )
const;
115 LUNCHBOX_API
void addQuery(
const std::string& key,
116 const std::string& value );
120 detail::URI*
const _impl;
123 inline std::ostream&
operator << ( std::ostream& os,
const URI& uri )
125 if( !uri.getScheme().empty( ))
126 os << uri.getScheme() <<
"://";
127 if( !uri.getUserinfo().empty( ))
128 os << uri.getUserinfo() <<
"@";
131 os <<
':' << uri.getPort();
133 if( !uri.getQuery().empty( ))
134 os <<
'?' << uri.getQuery();
135 if( !uri.getFragment().empty( ))
136 os <<
'#' << uri.getFragment();
143 template<>
inline std::string lexical_cast(
const lunchbox::URI& uri )
145 std::ostringstream os;
150 #endif // LUNCHBOX_URI_H
Defines export visibility macros for Lunchbox.
Basic type definitions not provided by the operating system.
LUNCHBOX_API URI()
Construct an empty URI.
LUNCHBOX_API URI & operator=(const URI &rhs)
Assign the data from another URI.
LUNCHBOX_API ConstKVIter queryBegin() const
The URI class parses the given uri string according to the regex given in RFC3986.
LUNCHBOX_API ConstKVIter queryEnd() const
LUNCHBOX_API ConstKVIter findQuery(const std::string &key) const
LUNCHBOX_API void addQuery(const std::string &key, const std::string &value)
Add a key-value pair to the query.
std::ostream & operator<<(std::ostream &os, const Array< T > &array)
Pretty-print all members of the array.