one of the following methods
\helpref{GetScheme}{wxurigetscheme}\\
-\helpref{GetUser}{wxurigetuser}\\
+\helpref{GetUserInfo}{wxurigetuserinfo}\\
\helpref{GetServer}{wxurigetserver}\\
\helpref{GetPort}{wxurigetserver}\\
\helpref{GetPath}{wxurigetpath}\\
NULL C string.\\
\\
\helpref{HasScheme}{wxurihasscheme}\\
-\helpref{HasUser}{wxurihasuser}\\
+\helpref{HasUserInfo}{wxurihasuserinfo}\\
\helpref{HasServer}{wxurihasserver}\\
\helpref{HasPort}{wxurihasserver}\\
\helpref{HasPath}{wxurihaspath}\\
\twocolitem{{\bf wxURI\_IPVFUTURE}}{Server is an IP address, but not versions 4 or 6}
\end{twocollist}
+
+\membersection{wxURI::GetPassword}\label{wxurigetpassword}
+
+\constfunc{const wxString&}{GetPassword}{\void}
+
+Returns the password part of the userinfo component of
+this URI. Note that this is explicitly depreciated by
+RFC 1396 and should generally be avoided if possible.
+
+\tt{http://<user>:<password>@mysite.com/mypath}
+
+
\membersection{wxURI::GetPath}\label{wxurigetpath}
\constfunc{const wxString&}{GetPath}{\void}
\constfunc{const wxString&}{GetUser}{\void}
-Returns the User component of the URI.
+Returns the username part of the userinfo component of
+this URI. Note that this is explicitly depreciated by
+RFC 1396 and should generally be avoided if possible.
+
+\tt{http://<user>:<password>@mysite.com/mypath}
+
+
+\membersection{wxURI::GetUserInfo}\label{wxurigetuserinfo}
+
+\constfunc{const wxString&}{GetUserInfo}{\void}
+
+Returns the UserInfo component of the URI.
The component of a URI before the server component
that is postfixed by a '@' character.
-\tt{http://<user>@mysite.com/mypath}
+\tt{http://<userinfo>@mysite.com/mypath}
+
\membersection{wxURI::HasFragment}\label{wxurihasfragment}
Returns \true if the Fragment component of the URI exists.
+
\membersection{wxURI::HasPath}\label{wxurihaspath}
\constfunc{bool}{HasPath}{\void}
Returns \true if the Path component of the URI exists.
+
\membersection{wxURI::HasPort}\label{wxurihasport}
\constfunc{bool}{HasPort}{\void}
enum wxURIFieldType
{
wxURI_SCHEME = 1,
- wxURI_USER = 2,
+ wxURI_USERINFO = 2,
wxURI_SERVER = 4,
wxURI_PORT = 8,
wxURI_PATH = 16,
const wxChar* Create(const wxString& uri);
bool HasScheme() const { return (m_fields & wxURI_SCHEME) == wxURI_SCHEME; }
- bool HasUser() const { return (m_fields & wxURI_USER) == wxURI_USER; }
+ bool HasUserInfo() const { return (m_fields & wxURI_USERINFO) == wxURI_USERINFO; }
bool HasServer() const { return (m_fields & wxURI_SERVER) == wxURI_SERVER; }
bool HasPort() const { return (m_fields & wxURI_PORT) == wxURI_PORT; }
bool HasPath() const { return (m_fields & wxURI_PATH) == wxURI_PATH; }
const wxString& GetQuery() const { return m_query; }
const wxString& GetFragment() const { return m_fragment; }
const wxString& GetPort() const { return m_port; }
- const wxString& GetUser() const { return m_user; }
+ const wxString& GetUserInfo() const { return m_userinfo; }
const wxString& GetServer() const { return m_server; }
const wxURIHostType& GetHostType() const { return m_hostType; }
+ //Note that the following two get functions are explicitly depreciated by RFC 2396
+ wxString GetUser() const;
+ wxString GetPassword() const;
+
wxString BuildURI() const;
wxString BuildUnescapedURI() const;
const wxChar* Parse (const wxChar* uri);
const wxChar* ParseAuthority (const wxChar* uri);
const wxChar* ParseScheme (const wxChar* uri);
- const wxChar* ParseUser (const wxChar* uri);
+ const wxChar* ParseUserInfo (const wxChar* uri);
const wxChar* ParseServer (const wxChar* uri);
const wxChar* ParsePort (const wxChar* uri);
const wxChar* ParsePath (const wxChar* uri,
wxString m_query;
wxString m_fragment;
- wxString m_user;
+ wxString m_userinfo;
wxString m_server;
wxString m_port;
void wxURI::Clear()
{
- m_scheme = m_user = m_server = m_port = m_path =
+ m_scheme = m_userinfo = m_server = m_port = m_path =
m_query = m_fragment = wxEmptyString;
m_hostType = wxURI_REGNAME;
return false;
}
+// ---------------------------------------------------------------------------
+// GetUser
+// GetPassword
+//
+// Gets the username and password via the old URL method.
+// ---------------------------------------------------------------------------
+wxString wxURI::GetUser() const
+{
+ size_t dwPasswordPos = m_userinfo.find(':');
+
+ if (dwPasswordPos == wxString::npos)
+ dwPasswordPos = 0;
+
+ return m_userinfo(0, dwPasswordPos);
+}
+
+wxString wxURI::GetPassword() const
+{
+ size_t dwPasswordPos = m_userinfo.find(':');
+
+ if (dwPasswordPos == wxString::npos)
+ return wxT("");
+ else
+ return m_userinfo(dwPasswordPos+1, m_userinfo.length() + 1);
+}
+
// ---------------------------------------------------------------------------
// BuildURI
//
{
ret += wxT("//");
- if (HasUser())
- ret = ret + m_user + wxT("@");
+ if (HasUserInfo())
+ ret = ret + m_userinfo + wxT("@");
ret += m_server;
{
ret += wxT("//");
- if (HasUser())
- ret = ret + wxURI::Unescape(m_user) + wxT("@");
+ if (HasUserInfo())
+ ret = ret + wxURI::Unescape(m_userinfo) + wxT("@");
if (m_hostType == wxURI_REGNAME)
ret += wxURI::Unescape(m_server);
//ref over components
m_scheme = uri.m_scheme;
- m_user = uri.m_user;
+ m_userinfo = uri.m_userinfo;
m_server = uri.m_server;
m_hostType = uri.m_hostType;
m_port = uri.m_port;
if (HasServer())
{
- if (HasUser())
+ if (HasUserInfo())
{
- if (m_user != uri.m_user)
+ if (m_userinfo != uri.m_userinfo)
return false;
}
- else if (uri.HasUser())
+ else if (uri.HasUserInfo())
return false;
if (m_server != uri.m_server ||
{
uri += 2;
- uri = ParseUser(uri);
+ uri = ParseUserInfo(uri);
uri = ParseServer(uri);
return ParsePort(uri);
}
return uri;
}
-const wxChar* wxURI::ParseUser(const wxChar* uri)
+const wxChar* wxURI::ParseUserInfo(const wxChar* uri)
{
wxASSERT(uri != NULL);
{
if(IsUnreserved(*uri) || IsEscape(uri) ||
IsSubDelim(*uri) || *uri == wxT(':'))
- m_user += *uri++;
+ m_userinfo += *uri++;
else
- Escape(m_user, *uri++);
+ Escape(m_userinfo, *uri++);
}
if(*uri == wxT('@'))
{
//valid userinfo
- m_fields |= wxURI_USER;
+ m_fields |= wxURI_USERINFO;
uricopy = ++uri;
}
else
- m_user = wxEmptyString;
+ m_userinfo = wxEmptyString;
return uricopy;
}
}
//No authority - inherit
- if (base.HasUser())
+ if (base.HasUserInfo())
{
- m_user = base.m_user;
- m_fields |= wxURI_USER;
+ m_userinfo = base.m_userinfo;
+ m_fields |= wxURI_USERINFO;
}
m_server = base.m_server;
}
m_error = wxURL_NOERR;
- if (HasUser())
+ if (HasUserInfo())
{
- size_t dwPasswordPos = m_user.find(':');
+ size_t dwPasswordPos = m_userinfo.find(':');
if (dwPasswordPos == wxString::npos)
- m_protocol->SetUser(m_user);
+ m_protocol->SetUser(m_userinfo);
else
{
- m_protocol->SetUser(m_user(0, dwPasswordPos));
- m_protocol->SetPassword(m_user(dwPasswordPos+1, m_user.length() + 1));
+ m_protocol->SetUser(m_userinfo(0, dwPasswordPos));
+ m_protocol->SetPassword(m_userinfo(dwPasswordPos+1, m_userinfo.length() + 1));
}
}