TagLib::FileRef Class Reference
This class provides a simple abstraction for creating and handling files. More...
#include <fileref.h>
Public Member Functions | |
FileRef (const char *fileName, bool readAudioProperties=true, AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average) | |
FileRef (File *file) | |
FileRef (const FileRef &ref) | |
virtual | ~FileRef () |
Tag * | tag () const |
AudioProperties * | audioProperties () const |
File * | file () const |
void | save () |
bool | isNull () const |
FileRef & | operator= (const FileRef &ref) |
bool | operator== (const FileRef &ref) const |
bool | operator!= (const FileRef &ref) const |
Static Public Member Functions | |
File * | create (const char *fileName, bool readAudioProperties=true, AudioProperties::ReadStyle audioPropertiesStyle=AudioProperties::Average) |
Detailed Description
This class provides a simple abstraction for creating and handling files.FileRef exists to provide a minimal, generic and value-based wrapper around a File. It is lightweight and implicitly shared, and as such suitable for pass-by-value use. This hides some of the uglier details of TagLib::File and the non-generic portions of the concrete file implementations.
This class is useful in a "simple usage" situation where it is desirable to be able to get and set some of the tag information that is similar across file types.
Also note that it is probably a good idea to plug this into your mime type system rather than using the constructor that accepts a file name.
For example in KDE this could be done with:
TagLib::FileRef createFileRef( const QString &fileName ) { KMimeType::Ptr result = KMimeType::findByPath( fileName, 0, true ); if( result->name() == "audio/x-mp3" ) return FileRef( new MPEG::File( QFile::encodeName( fileName ).data() ) ); if( result->name() == "application/ogg" ) return FileRef( new Vorbis::File( QFile::encodeName( fileName ).data() ) ); return FileRef( 0 ); }
Definition at line 68 of file fileref.h.
Constructor & Destructor Documentation
|
Create a FileRef from fileName. If readAudioProperties is true then the audio properties will be read using audioPropertiesStyle. If readAudioProperties is false then audioPropertiesStyle will be ignored. Also see the note in the class documentation about why you may not want to use this method in your application. |
|
Contruct a FileRef using file. The FileRef now takes ownership of the pointer and will delete the File when it passes out of scope. |
|
Make a copy of ref. |
|
Destroys this FileRef instance. |
Member Function Documentation
|
Returns a pointer to represented file's tag.
|
|
Returns the audio properties for this FileRef. If no audio properties were read then this will returns a null pointer. |
|
Returns a pointer to the file represented by this handler class. As a general rule this call should be avoided since if you need to work with file objects directly, you are probably better served instantiating the File subclasses (i.e. MPEG::File) manually and working with their APIs. This handle exists to provide a minimal, generic and value-based wrapper around a File. Accessing the file directly generally indicates a moving away from this simplicity (and into things beyond the scope of FileRef).
|
|
Saves the file. |
|
Returns true if the file (and as such other pointers) are null. |
|
Assign the file pointed to by ref to this FileRef. |
|
Returns true if this FileRef and ref point to the same File object. |
|
Returns true if this FileRef and ref do not point to the same File object. |
|
A simple implementation of file type guessing. If readAudioProperties is true then the audio properties will be read using audioPropertiesStyle. If readAudioProperties is false then audioPropertiesStyle will be ignored.
|
The documentation for this class was generated from the following file: