# wxMimeTypesManager Class Reference
[Application and System configuration]

`#include <wx/mimetype.h>`

## Detailed Description

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

MIME stands for "Multipurpose Internet Mail Extensions" and was originally used in mail protocols. It's standardized by several RFCs.

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 wxTheMimeTypesManager. The functions GetFileTypeFromMimeType() and GetFileTypeFromExtension() return a wxFileType object which may be further queried for file description, icon and other attributes.

## 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.

- wxMimeTypesManager::IsOfType()

## 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.

- wxMimeTypesManager::GetFileTypeFromMimeType()
- wxMimeTypesManager::GetFileTypeFromExtension()

##

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.
wxFileType * | 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.
wxFileType * | 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 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.

|  | [ top ]