34 #include <boost/regex.hpp> 36 static const std::string
regex_scheme =
"(?<SCHEME_TYPE>[^\\]\\[:/?#@!$&'()*+,;=]+?):";
38 static const std::string
regex_userInfo =
"((?<USER_TYPE>.+):(?<PASSWORD_TYPE>.*)@)?";
40 static const std::string
regex_host =
"(?<HOST_TYPE>[^\\]\\[:/?#@!$&'()*+,;=]+)";
42 static const std::string
regex_port =
"(:(?<PORT_TYPE>[0-9]{1,5}))?";
44 static const std::string
regex_path =
"(?<PATH_TYPE>[^\\]\\[?#!$&'()*+,;=]+)?";
46 static const std::string
regex_query =
"(\\?(?<QUERY_TYPE>[^\\]\\[?#@!$'()*+,]+)?)?";
53 boost::match_results< std::string::const_iterator >
m_match;
83 URI(other).swap(*
this);
95 return m_pimpl->m_match[
"SCHEME_TYPE"].str();
100 return m_pimpl->m_match[
"USER_TYPE"].str();
105 return m_pimpl->m_match[
"PASSWORD_TYPE"].str();
110 return m_pimpl->m_match[
"HOST_TYPE"].str();
115 return m_pimpl->m_match[
"PORT_TYPE"].str();
120 return m_pimpl->m_match[
"PATH_TYPE"].str();
125 return m_pimpl->m_match[
"QUERY_TYPE"].str();
130 return m_pimpl->m_match[
"FRAGMENT_TYPE"].str();
156 boost::match_results< std::string::const_iterator > match;
162 if(boost::regex_match(
m_pimpl->m_uri, match, expression, boost::match_default))
173 if(boost::regex_match(
m_pimpl->m_uri, match, expression, boost::match_default))
185 std::string::const_iterator it = std::begin(
m_pimpl->m_uri);
187 while(it != std::end(
m_pimpl->m_uri))
189 int ASCIIvalue = *it;
191 if(ASCIIvalue < 33 || ASCIIvalue > 126)
213 switch (ASCIIvalue) {
225 value = ASCIIvalue +
'0';
235 value = ASCIIvalue - 10 +
'A';
239 return std::string();
static const std::string regex_host
std::string path() const
Retrieving the path.
std::string scheme() const
Retrieving the scheme.
std::string fragment() const
Retrieving the fragment.
std::string password() const
Retrieving the password information.
bool isValid() const
Return if the given URI is valid or not.
static const std::string regex_port
URI()
Default constructor.
static const std::string regex_scheme
std::string query() const
Retrieving the query.
static const std::string regex_path
void parse()
Parse the URI stored in uri_ member.
void swap(URI &other)
Swap operation.
static const std::string regex_userInfo
std::string port() const
Retrieving the port.
std::string host() const
Retrieving the host.
std::string hexToLetter(int i)
const std::string & uri() const
Retrieving the full URI.
A class for representing an Uniform Resource Identifier (URI).
std::unique_ptr< Impl > m_pimpl
void encode()
Check if the uri_ contains any invalid character and parse it to his hexadecimal value.
static const std::string regex_query
static const std::string regex_fragment
A class for representing an Uniform Resource Identifier (URI).
boost::match_results< std::string::const_iterator > m_match
URI & operator=(const URI &other)
Assingment operator.
std::string user() const
Retrieving the user information.