Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::MimeType Class Reference

Immutable, value-type wrapper for a registered mime-type. More...

#include <mitkMimeType.h>

Public Member Functions

 MimeType ()
 Construct a default (invalid) MimeType. More...
 
 MimeType (const MimeType &other)
 Copy constructor. More...
 
 MimeType (const CustomMimeType &x, int rank, long id)
 Construct a MimeType from a CustomMimeType with a service rank and id. More...
 
 ~MimeType ()
 
MimeType & operator= (const MimeType &other)
 Copy assignment operator. More...
 
bool operator== (const MimeType &other) const
 Equality comparison based on the mime-type name. More...
 
bool operator< (const MimeType &other) const
 Less-than comparison based on rank and service id. More...
 
std::string GetName () const
 Get the unique name of this mime-type. More...
 
std::string GetCategory () const
 Get the human-readable category (e.g. "Images", "Surfaces"). More...
 
std::vector< std::string > GetExtensions () const
 Get the list of file extensions this mime-type handles. More...
 
std::string GetComment () const
 Get a human-readable comment describing this mime-type. More...
 
std::string GetFilenameWithoutExtension (const std::string &path) const
 Extract the filename without the matching extension from a path. More...
 
bool AppliesTo (const std::string &path) const
 Check whether this mime-type can handle the given file path. More...
 
bool MatchesExtension (const std::string &path) const
 Check whether the extension of the given path matches this mime-type. More...
 
bool IsValid () const
 Check whether this MimeType object is valid (has a non-empty name). More...
 
void Swap (MimeType &m)
 Swap the contents of this MimeType with another. More...
 

Detailed Description

Immutable, value-type wrapper for a registered mime-type.

MimeType wraps a mitk::CustomMimeType with copy-on-write semantics, providing a stack-friendly, memory-safe handle for consumers that need to query mime-type information without managing raw pointers.

To register a new mime-type, use the CustomMimeType class instead. Wrapping into a MimeType is performed automatically by the framework. In all other cases you should use mitk::MimeType when working with mime-types.

See also
CustomMimeType
IMimeTypeProvider
IOMimeTypes

Definition at line 44 of file mitkMimeType.h.

Constructor & Destructor Documentation

◆ MimeType() [1/3]

mitk::MimeType::MimeType ( )

Construct a default (invalid) MimeType.

◆ MimeType() [2/3]

mitk::MimeType::MimeType ( const MimeType &  other)

Copy constructor.

Parameters
[in]otherThe MimeType to copy from.

◆ MimeType() [3/3]

mitk::MimeType::MimeType ( const CustomMimeType &  x,
int  rank,
long  id 
)

Construct a MimeType from a CustomMimeType with a service rank and id.

Parameters
[in]xThe CustomMimeType to wrap.
[in]rankThe service ranking of this mime-type.
[in]idThe service id of this mime-type.

◆ ~MimeType()

mitk::MimeType::~MimeType ( )

Member Function Documentation

◆ AppliesTo()

bool mitk::MimeType::AppliesTo ( const std::string &  path) const

Check whether this mime-type can handle the given file path.

Parameters
[in]pathThe file path to check.
Returns
true if this mime-type applies to the given path.
See also
CustomMimeType::AppliesTo()

◆ GetCategory()

std::string mitk::MimeType::GetCategory ( ) const

Get the human-readable category (e.g. "Images", "Surfaces").

Returns
The category string.
See also
CustomMimeType::GetCategory()

◆ GetComment()

std::string mitk::MimeType::GetComment ( ) const

Get a human-readable comment describing this mime-type.

Returns
The comment string.
See also
CustomMimeType::GetComment()

◆ GetExtensions()

std::vector<std::string> mitk::MimeType::GetExtensions ( ) const

Get the list of file extensions this mime-type handles.

Returns
A vector of file extensions (without leading dots).
See also
CustomMimeType::GetExtensions()

◆ GetFilenameWithoutExtension()

std::string mitk::MimeType::GetFilenameWithoutExtension ( const std::string &  path) const

Extract the filename without the matching extension from a path.

Parameters
[in]pathThe file path to process.
Returns
The filename without the extension matched by this mime-type.
See also
CustomMimeType::GetFilenameWithoutExtension()

◆ GetName()

std::string mitk::MimeType::GetName ( ) const

Get the unique name of this mime-type.

Returns
The mime-type name (e.g. "application/vnd.mitk.image.nrrd").
See also
CustomMimeType::GetName()

◆ IsValid()

bool mitk::MimeType::IsValid ( ) const

Check whether this MimeType object is valid (has a non-empty name).

Returns
true if this MimeType has been properly initialized with a name.

Referenced by mitk::MimeTypeTrackerTypeTraits::IsValid().

◆ MatchesExtension()

bool mitk::MimeType::MatchesExtension ( const std::string &  path) const

Check whether the extension of the given path matches this mime-type.

Parameters
[in]pathThe file path to check.
Returns
true if the path's extension matches one of this mime-type's extensions.
See also
CustomMimeType::MatchesExtension()

◆ operator<()

bool mitk::MimeType::operator< ( const MimeType &  other) const

Less-than comparison based on rank and service id.

Parameters
[in]otherThe MimeType to compare with.
Returns
true if this MimeType is ranked lower than other.

◆ operator=()

MimeType& mitk::MimeType::operator= ( const MimeType &  other)

Copy assignment operator.

Parameters
[in]otherThe MimeType to assign from.
Returns
Reference to this object.

◆ operator==()

bool mitk::MimeType::operator== ( const MimeType &  other) const

Equality comparison based on the mime-type name.

Parameters
[in]otherThe MimeType to compare with.
Returns
true if both MimeType objects have the same name.

◆ Swap()

void mitk::MimeType::Swap ( MimeType &  m)

Swap the contents of this MimeType with another.

Parameters
[in,out]mThe MimeType to swap with.

The documentation for this class was generated from the following file: