wxMimeTypesManager Class Reference
[Application and System configuration]

#include <wx/mimetype.h>


Detailed Description

This class allows the application to retrieve the information about all known MIME types from a system-specific location and the filename extensions to the MIME types and vice versa.

After initialization the functions GetFileTypeFromMimeType() and GetFileTypeFromExtension() may be called: they will return a wxFileType object which may be further queried for file description, icon and other attributes.

Under Windows, the MIME type information is queried from registry. Under Linux and Unix, it is queried from the XDG data directories.

Currently, wxMimeTypesManager is limited to reading MIME type information.

The application should not construct its own manager: it should use the object pointer wxTheMimeTypesManger.

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.

Constructor and destructor

NB: You won't normally need to use more than one wxMimeTypesManager object in a program.

Query database

These functions are the heart of this class: they allow to find a file type object from either file extension or MIME type. If the function is successful, it returns a pointer to the wxFileType object which must be deleted by the caller, otherwise NULL will be returned.

Initialization functions

Unix: These functions may be used to load additional files (except for the default ones which are loaded automatically) containing MIME information in either mailcap(5) or mime.types(5) format.

Library:  wxBase
Category:  Application and System configuration
See also:
wxFileType

Public Member Functions

 wxMimeTypesManager ()
 Constructor puts the object in the "working" state.
 ~wxMimeTypesManager ()
 Destructor is not virtual, so this class should not be derived from.
void AddFallbacks (const wxFileTypeInfo *fallbacks)
 This function may be used to provide hard-wired fallbacks for the MIME types and extensions that might not be present in the system MIME database.
wxFileTypeGetFileTypeFromExtension (const wxString &extension)
 Gather information about the files with given extension and return the corresponding wxFileType object or NULL if the extension is unknown.
wxFileTypeGetFileTypeFromMimeType (const wxString &mimeType)
 Gather information about the files with given MIME type and return the corresponding wxFileType object or NULL if the MIME type is unknown.

Static Public Member Functions

static bool IsOfType (const wxString &mimeType, const wxString &wildcard)
 This function returns true if either the given mimeType is exactly the same as wildcard or if it has the same category and the subtype of wildcard is '*'.

List of all members.


Constructor & Destructor Documentation

wxMimeTypesManager::wxMimeTypesManager (  ) 

Constructor puts the object in the "working" state.

wxMimeTypesManager::~wxMimeTypesManager (  ) 

Destructor is not virtual, so this class should not be derived from.


Member Function Documentation

void wxMimeTypesManager::AddFallbacks ( const wxFileTypeInfo *  fallbacks  ) 

This function may be used to provide hard-wired fallbacks for the MIME types and extensions that might not be present in the system MIME database.

Please see the typetest sample for an example of using it.

wxFileType* wxMimeTypesManager::GetFileTypeFromExtension ( const wxString extension  ) 

Gather information about the files with given extension and return the corresponding wxFileType object or NULL if the extension is unknown.

The extension parameter may have, or not, the leading dot, if it has it, it is stripped automatically. It must not however be empty.

wxFileType* wxMimeTypesManager::GetFileTypeFromMimeType ( const wxString mimeType  ) 

Gather information about the files with given MIME type and return the corresponding wxFileType object or NULL if the MIME type is unknown.

static bool wxMimeTypesManager::IsOfType ( const wxString mimeType,
const wxString wildcard 
) [static]

This function returns true if either the given mimeType is exactly the same as wildcard or if it has the same category and the subtype of wildcard is '*'.

Note that the '*' wildcard is not allowed in mimeType itself.

The comparison don by this function is case insensitive so it is not necessary to convert the strings to the same case before calling it.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



wxWidgets logo

[ top ]