TagLib::FileRef::StreamTypeResolver Class Referenceabstract

A class for pluggable stream type resolution. More...

`#include <fileref.h>`

Inheritance diagram for TagLib::FileRef::StreamTypeResolver:
[legend]
Collaboration diagram for TagLib::FileRef::StreamTypeResolver:
[legend]

## Public Member Functions

| StreamTypeResolver ()
virtual | ~StreamTypeResolver () override=0
| StreamTypeResolver (const StreamTypeResolver &)=delete
StreamTypeResolver & | operator= (const StreamTypeResolver &)=delete
virtual File * | createFileFromStream (IOStream *stream, bool readAudioProperties=true, AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average) const =0
Public Member Functions inherited from TagLib::FileRef::FileTypeResolver
| FileTypeResolver ()
virtual | ~FileTypeResolver ()=0
| FileTypeResolver (const FileTypeResolver &)=delete
FileTypeResolver & | operator= (const FileTypeResolver &)=delete
virtual File * | createFile (FileName fileName, bool readAudioProperties=true, AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average) const =0

## Detailed Description

A class for pluggable stream type resolution.

This class is used to extend TagLib's very basic file name based file type resolution.

This can be accomplished with:

class MyStreamTypeResolver : StreamTypeResolver
{
TagLib::File *createFile(TagLib::FileName *fileName, bool readProps,
AudioProperties::ReadStyle readStyle) const override
{
if(someCheckForAnMP3File(fileName))
return new TagLib::MPEG::File(fileName, readProps, readStyle);
return nullptr;
}
TagLib::File *createFileFromStream(TagLib::IOStream *s, bool readProps,
AudioProperties::ReadStyle readStyle) const override
{
if(someCheckForAnMP3Stream(s))
return new TagLib::MPEG::File(s, readProps, readStyle);
return nullptr;
}
}
FileRef::addFileTypeResolver(new MyStreamTypeResolver);
TagLib::AudioProperties::ReadStyle
ReadStyle
Definition audioproperties.h:56
TagLib::FileRef::FileTypeResolver::createFile
virtual File * createFile(FileName fileName, bool readAudioProperties=true, AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average) const =0
TagLib::FileRef::StreamTypeResolver::StreamTypeResolver
StreamTypeResolver()
TagLib::FileRef::StreamTypeResolver::createFileFromStream
virtual File * createFileFromStream(IOStream *stream, bool readAudioProperties=true, AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average) const =0
TagLib::FileRef::addFileTypeResolver
static const FileTypeResolver * addFileTypeResolver(const FileTypeResolver *resolver)
TagLib::File
A file class with some useful methods for tag manipulation.
Definition tfile.h:51
TagLib::IOStream
An abstract class that provides operations on a sequence of bytes.
Definition tiostream.h:65
TagLib::MPEG::File
An MPEG file class with some useful methods specific to MPEG.
Definition mpegfile.h:54
TagLib::FileName
const char * FileName
Definition tiostream.h:59

Naturally a less contrived example would be slightly more complex. This can be used to plug in mime-type detection systems or to add new file types to TagLib.

## Constructor & Destructor Documentation

## StreamTypeResolver() [1/2]

TagLib::FileRef::StreamTypeResolver::StreamTypeResolver | ( |  | ) |

Referenced by operator=(), and StreamTypeResolver().

## ~StreamTypeResolver()

virtual TagLib::FileRef::StreamTypeResolver::~StreamTypeResolver | ( |  | ) |

override pure virtual

Destroys this StreamTypeResolver instance.

## StreamTypeResolver() [2/2]

TagLib::FileRef::StreamTypeResolver::StreamTypeResolver | ( | const StreamTypeResolver & |  | ) |

delete

References StreamTypeResolver().

## Member Function Documentation

## createFileFromStream()

virtual File * TagLib::FileRef::StreamTypeResolver::createFileFromStream | ( | IOStream * | stream,
|  | bool | readAudioProperties = true,
|  | AudioProperties::ReadStyle | audioPropertiesStyle = AudioProperties::Average ) const

pure virtual

This method must be overridden to provide an additional stream type resolver. If the resolver is able to determine the file type it should return a valid File object; if not it should return nullptr.

Note
  The created file is then owned by the FileRef and should not be deleted. Deletion will happen automatically when the FileRef passes out of scope.

See also
  createFile()

References TagLib::AudioProperties::Average, and TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE.

## operator=()

StreamTypeResolver & TagLib::FileRef::StreamTypeResolver::operator= | ( | const StreamTypeResolver & |  | ) |

delete

References StreamTypeResolver().

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

- fileref.h