Logo
~Sockets~
~Examples~
~Contact~


Utility::Uri Class Reference

#include <Utility.h>

List of all members.


Public Member Functions

 Uri (const std::string &url)
const std::string & Url () const
const std::string & UrlUri () const
const std::string & QueryString () const
const std::string & Protocol () const
const std::string & Host () const
int Port () const
const std::string & Path () const
const std::string & File () const
const std::string & Extension () const
const std::string & ToString () const
const std::string & User () const
const std::string & Auth () const

Private Attributes

std::string m_url
std::string m_uri
std::string m_query_string
std::string m_protocol
std::string m_host
int m_port
std::string m_path
std::string m_file
std::string m_ext
std::string m_user
std::string m_auth

Detailed Description

Definition at line 78 of file Utility.h.


Constructor & Destructor Documentation

Utility::Uri::Uri ( const std::string &  url  ) 

Definition at line 1175 of file Utility.cpp.

References m_auth, m_ext, m_file, m_host, m_path, m_port, m_protocol, m_query_string, m_uri, m_user, and Utility::ToLower().

01175                                     : m_url(url), m_port(0), m_path(url)
01176 {
01177         size_t pos = url.find("://");
01178         if (pos != std::string::npos)
01179         {
01180                 m_protocol = Utility::ToLower(url.substr(0, pos));
01181                 m_port = (m_protocol == "http") ? 80 :
01182                         (m_protocol == "https") ? 443 : 0;
01183                 m_host = url.substr(pos + 3);
01184                 pos = m_host.find("/");
01185                 if (pos != std::string::npos)
01186                 {
01187                         m_path = m_host.substr(pos);
01188                         m_host = m_host.substr(0, pos);
01189                 }
01190                 pos = m_host.find("@");
01191                 if (pos != std::string::npos)
01192                 {
01193                         m_user = m_host.substr(0, pos);
01194                         m_host = m_host.substr(pos + 1);
01195                 }
01196                 pos = m_user.find(":");
01197                 if (pos != std::string::npos)
01198                 {
01199                         m_auth = m_user.substr(pos + 1);
01200                         m_user = m_user.substr(0, pos);
01201                 }
01202                 pos = m_host.find(":");
01203                 if (pos != std::string::npos)
01204                 {
01205                         m_port = atoi(m_host.substr(pos + 1).c_str());
01206                         m_host = m_host.substr(0, pos);
01207                 }
01208         }
01209         pos = m_path.find("?");
01210         if (pos != std::string::npos)
01211         {
01212                 m_uri = m_path.substr(0, pos);
01213                 m_query_string = m_path.substr(pos + 1);
01214         }
01215         else
01216         {
01217                 m_uri = m_path;
01218         }
01219         pos = std::string::npos;
01220         for (size_t i = 0; i < m_uri.size(); ++i)
01221                 if (m_uri[i] == '/')
01222                         pos = i;
01223         if (pos != std::string::npos)
01224                 m_file = m_uri.substr(pos + 1);
01225         pos = std::string::npos;
01226         for (size_t i = 0; i < m_uri.size(); ++i)
01227                 if (m_uri[i] == '.')
01228                         pos = i;
01229         if (pos != std::string::npos)
01230                 m_ext = m_uri.substr(pos + 1);
01231 }


Member Function Documentation

const std::string& Utility::Uri::Url (  )  const [inline]

Definition at line 82 of file Utility.h.

00082 { return m_url; }

const std::string& Utility::Uri::UrlUri (  )  const [inline]

Definition at line 83 of file Utility.h.

00083 { return m_uri; }

const std::string& Utility::Uri::QueryString (  )  const [inline]

Definition at line 84 of file Utility.h.

00084 { return m_query_string; }

const std::string& Utility::Uri::Protocol (  )  const [inline]

Definition at line 85 of file Utility.h.

00085 { return m_protocol; }

const std::string& Utility::Uri::Host (  )  const [inline]

Definition at line 86 of file Utility.h.

00086 { return m_host; }

int Utility::Uri::Port (  )  const [inline]

Definition at line 87 of file Utility.h.

00087 { return m_port; }

const std::string& Utility::Uri::Path (  )  const [inline]

Definition at line 88 of file Utility.h.

00088 { return m_path; }

const std::string& Utility::Uri::File (  )  const [inline]

Definition at line 89 of file Utility.h.

00089 { return m_file; }

const std::string& Utility::Uri::Extension (  )  const [inline]

Definition at line 90 of file Utility.h.

00090 { return m_ext; }

const std::string& Utility::Uri::ToString (  )  const [inline]

Definition at line 92 of file Utility.h.

00092 { return m_url; }

const std::string& Utility::Uri::User (  )  const [inline]

Definition at line 94 of file Utility.h.

00094 { return m_user; }

const std::string& Utility::Uri::Auth (  )  const [inline]

Definition at line 95 of file Utility.h.

00095 { return m_auth; }


Member Data Documentation

std::string Utility::Uri::m_url [private]

Definition at line 98 of file Utility.h.

std::string Utility::Uri::m_uri [private]

Definition at line 99 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_query_string [private]

Definition at line 100 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_protocol [private]

Definition at line 101 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_host [private]

Definition at line 102 of file Utility.h.

Referenced by Uri().

int Utility::Uri::m_port [private]

Definition at line 103 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_path [private]

Definition at line 104 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_file [private]

Definition at line 105 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_ext [private]

Definition at line 106 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_user [private]

Definition at line 107 of file Utility.h.

Referenced by Uri().

std::string Utility::Uri::m_auth [private]

Definition at line 108 of file Utility.h.

Referenced by Uri().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4