wxMimeTypesManager::IsOfType() added (and documented)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-02-18 14:23:24 +00:00
parent d37fd2fada
commit a5a19b8360
2 changed files with 43 additions and 0 deletions

View File

@ -36,6 +36,15 @@ No base class.
\latexignore{\rtfignore{\wxheading{Function groups}}}
\membersection{Helper functions}
All of these functions are static (i.e. don't need a wxMimeTypesManager object
to call them) and provide some useful operations for string representations of
MIME types. Their usage is recommended instead of directly working with MIME
types using wxString functions.
\helpref{IsOfType}{wxmimetypesmanagerisoftype}
\membersection{Constructor and destructor}
NB: You won't normally need to use more than one wxMimeTypesManager object in a
@ -100,6 +109,18 @@ Gather information about the files with given MIME type and return the
corresponding \helpref{wxFileType}{wxfiletype} object or NULL if the MIME type
is unknown.
\membersection{wxMimeTypesManager::IsOfType}\label{wxmimetypesmanagerisoftype}
\func{bool}{IsOfType}{\param{const wxString\&}{ mimeType}, \param{const wxString\&}{ wildcard}}
This function returns TRUE if either the given {\it mimeType} is exactly the
same as {\it wildcard} or if it has the same category and the subtype of
{\it wildcard} is '*'. Note that the '*' wildcard is not allowed in
{\it mimeType} itself.
The comparaison don by this function is case insensitive so it is not
necessary to convert the strings to the same case before calling it.
\membersection{wxMimeTypesManager::ReadMailcap}\label{wxmimetypesmanagerreadmailcap}
\func{void}{ReadMailcap}{\param{const wxString\&}{ filename}}

View File

@ -448,6 +448,28 @@ wxFileType::GetPrintCommand(wxString *printCmd,
// wxMimeTypesManager
// ----------------------------------------------------------------------------
bool wxMimeTypesManager::IsOfType(const wxString& mimeType,
const wxString& wildcard)
{
wxASSERT_MSG( mimeType.Find('*') == wxNOT_FOUND,
"first MIME type can't contain wildcards" );
// all comparaisons are case insensitive (2nd arg of IsSameAs() is FALSE)
if ( wildcard.BeforeFirst('/').IsSameAs(mimeType.BeforeFirst('/'), FALSE) )
{
wxString strSubtype = wildcard.AfterFirst('/');
if ( strSubtype == '*' ||
strSubtype.IsSameAs(mimeType.AfterFirst('/'), FALSE) )
{
// matches (either exactly or it's a wildcard)
return TRUE;
}
}
return FALSE;
}
wxMimeTypesManager::wxMimeTypesManager()
{
m_impl = new wxMimeTypesManagerImpl;