From 8404931e0d899429c99c0081b18703e8609eb94a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 28 Oct 2004 01:03:38 +0000 Subject: [PATCH] minor cleanup: don't use bool parameters, don't typedef the enums, don't abuse references git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30133 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/uri.tex | 7 ++++--- include/wx/uri.h | 37 +++++++++++++++++++++++-------------- src/common/uri.cpp | 17 +++++++++-------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/docs/latex/wx/uri.tex b/docs/latex/wx/uri.tex index 761fd76830..5b1bfab4bb 100644 --- a/docs/latex/wx/uri.tex +++ b/docs/latex/wx/uri.tex @@ -281,7 +281,7 @@ this URI equals {\tt uricomp}, otherwise it returns false. \membersection{wxURI::Resolve}\label{wxuriresolve} -\func{void}{Resolve}{\param{const wxURI\& }{base}, \param{const bool\& }{bStrict = true}} +\func{void}{Resolve}{\param{const wxURI\& }{base}, \param{int }{flags = \texttt{wxURI\_STRICT}}} Inherits this URI from a base URI - components that do not exist in this URI are copied from the base, and if this URI's @@ -296,6 +296,7 @@ of the base's is merged with this URI's path, resulting in the URI "http://mysite.com/john/mydir". \docparam{base}{Base URI to inherit from. Must be a full URI and not a reference} -\docparam{bStrict}{If false, some compatability layers are enabled to allow - loopholes from RFCs prior to 2396} +\docparam{flags}{Currently either \texttt{wxURI\_STRICT} or $0$, in non strict +mode some compatability layers are enabled to allow loopholes from RFCs prior +to 2396} diff --git a/include/wx/uri.h b/include/wx/uri.h index 706e5010cf..03a9fba8db 100644 --- a/include/wx/uri.h +++ b/include/wx/uri.h @@ -8,8 +8,8 @@ // Licence: wxWindows ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_URIH__ -#define _WX_URIH__ +#ifndef _WX_URI_H_ +#define _WX_URI_H_ #if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "uri.h" @@ -20,16 +20,16 @@ #include "wx/string.h" // Host Type that the server can be -typedef enum +enum wxURIHostType { wxURI_REGNAME, wxURI_IPV4ADDRESS, wxURI_IPV6ADDRESS, wxURI_IPVFUTURE -} wxURIHostType; +}; // Component Flags -typedef enum +enum wxURIFieldType { wxURI_SCHEME = 1, wxURI_USER = 2, @@ -38,7 +38,14 @@ typedef enum wxURI_PATH = 16, wxURI_QUERY = 32, wxURI_FRAGMENT = 64 -} wxURIFieldType; +}; + +// Miscellaneous other flags +enum wxURIFlags +{ + wxURI_STRICT = 1 +}; + // Generic class for parsing URIs. // @@ -52,7 +59,7 @@ public: wxURI(const wxString& uri); wxURI(const wxURI& uri); - ~wxURI(); + virtual ~wxURI(); void Create(const wxString& uri); @@ -75,7 +82,7 @@ public: wxString Get() const; - void Resolve(const wxURI& base, const bool& bStrict = true); + void Resolve(const wxURI& base, int flags = wxURI_STRICT); bool IsReference() const; wxURI& operator = (const wxURI& uri); @@ -92,8 +99,9 @@ protected: const wxChar* ParseUser (const wxChar* uri); const wxChar* ParseServer (const wxChar* uri); const wxChar* ParsePort (const wxChar* uri); - const wxChar* ParsePath (const wxChar* uri, const bool& bReference = false, - const bool& bNormalize = true); + const wxChar* ParsePath (const wxChar* uri, + bool bReference = false, + bool bNormalize = true); const wxChar* ParseQuery (const wxChar* uri); const wxChar* ParseFragment (const wxChar* uri); @@ -104,10 +112,10 @@ protected: static bool ParseIPvFuture(const wxChar*& uri); - static void Normalize(wxChar* uri, const bool& bIgnoreLeads = false); + static void Normalize(wxChar* uri, bool bIgnoreLeads = false); static void UpTree(const wxChar* uristart, const wxChar*& uri); - static void Unescape(const wxChar*& s, wxChar& c); + static wxChar Unescape(const wxChar* s); static void Escape (wxString& s, const wxChar& c); static bool IsEscape(const wxChar*& uri); @@ -136,6 +144,7 @@ protected: size_t m_fields; DECLARE_DYNAMIC_CLASS(wxURI) -};//end of wxURI +}; + +#endif // _WX_URI_H_ -#endif //_WX_URIH__ diff --git a/src/common/uri.cpp b/src/common/uri.cpp index c623956177..e37c99ccd0 100644 --- a/src/common/uri.cpp +++ b/src/common/uri.cpp @@ -109,10 +109,11 @@ void wxURI::Create(const wxString& uri) // if it does, then it moves the input string past the escape sequence // --------------------------------------------------------------------------- -void wxURI::Unescape(const wxChar*& s, wxChar& c) +wxChar wxURI::Unescape(const wxChar* s) { wxASSERT_MSG(IsHex(*s) && IsHex(*(s+1)), wxT("Invalid escape!")); - c = CharToHex(*s) * 0x10 + CharToHex(*++s); + + return CharToHex(*s) * 0x10 + CharToHex(*++s); } void wxURI::Escape(wxString& s, const wxChar& c) @@ -539,7 +540,7 @@ const wxChar* wxURI::ParsePort(const wxChar* uri) return uri; } -const wxChar* wxURI::ParsePath(const wxChar* uri, const bool& bReference, const bool& bNormalize) +const wxChar* wxURI::ParsePath(const wxChar* uri, bool bReference, bool bNormalize) { wxASSERT(uri != NULL); @@ -693,7 +694,7 @@ const wxChar* wxURI::ParseFragment(const wxChar* uri) // (it is shown in comments) // --------------------------------------------------------------------------- -void wxURI::Resolve(const wxURI& base, const bool& bStrict) +void wxURI::Resolve(const wxURI& base, int flags) { wxASSERT_MSG(!base.IsReference(), wxT("wxURI to inherit from must not be a reference!")); @@ -702,9 +703,9 @@ void wxURI::Resolve(const wxURI& base, const bool& bStrict) // loophole that allows this uri to inherit other // properties from the base uri - even if the scheme // is defined - if (!bStrict && - HasScheme() && base.HasScheme() && - this->m_scheme == base.m_scheme ) + if ( !(flags & wxURI_STRICT) && + HasScheme() && base.HasScheme() && + m_scheme == base.m_scheme ) { m_fields -= wxURI_SCHEME; } @@ -841,7 +842,7 @@ void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri) //!!!// } -void wxURI::Normalize(wxChar* s, const bool& bIgnoreLeads) +void wxURI::Normalize(wxChar* s, bool bIgnoreLeads) { wxChar* cp = s; wxChar* bp = s; -- 2.45.2