![]() |
Miam-Player
0.8.0
A nice music player
|
The main class in the ID3v2 implementation. More...
#include <id3v2tag.h>
Public Member Functions | |
Tag () | |
Constructs an empty ID3v2 tag. More... | |
Tag (File *file, long tagOffset, const FrameFactory *factory=FrameFactory::instance()) | |
Constructs an ID3v2 tag read from file starting at tagOffset. More... | |
virtual | ~Tag () |
Destroys this Tag instance. More... | |
virtual String | title () const |
Returns the track name; if no track name is present in the tag String::null will be returned. More... | |
virtual String | artist () const |
Returns the artist name; if no artist name is present in the tag String::null will be returned. More... | |
virtual String | album () const |
Returns the album name; if no album name is present in the tag String::null will be returned. More... | |
virtual String | comment () const |
Returns the track comment; if no comment is present in the tag String::null will be returned. More... | |
virtual String | genre () const |
Returns the genre name; if no genre is present in the tag String::null will be returned. More... | |
virtual unsigned int | year () const |
Returns the year; if there is no year set, this will return 0. More... | |
virtual unsigned int | track () const |
Returns the track number; if there is no track number set, this will return 0. More... | |
virtual void | setTitle (const String &s) |
Sets the title to s. More... | |
virtual void | setArtist (const String &s) |
Sets the artist to s. More... | |
virtual void | setAlbum (const String &s) |
Sets the album to s. More... | |
virtual void | setComment (const String &s) |
Sets the comment to s. More... | |
virtual void | setGenre (const String &s) |
Sets the genre to s. More... | |
virtual void | setYear (unsigned int i) |
Sets the year to i. More... | |
virtual void | setTrack (unsigned int i) |
Sets the track to i. More... | |
virtual bool | isEmpty () const |
Returns true if the tag does not contain any data. More... | |
Header * | header () const |
Returns a pointer to the tag's header. More... | |
ExtendedHeader * | extendedHeader () const |
Returns a pointer to the tag's extended header or null if there is no extended header. More... | |
Footer * | footer () const |
Returns a pointer to the tag's footer or null if there is no footer. More... | |
const FrameListMap & | frameListMap () const |
Returns a reference to the frame list map. More... | |
const FrameList & | frameList () const |
Returns a reference to the frame list. More... | |
const FrameList & | frameList (const ByteVector &frameID) const |
Returns the frame list for frames with the id frameID or an empty list if there are no frames of that type. More... | |
void | addFrame (Frame *frame) |
Add a frame to the tag. More... | |
void | removeFrame (Frame *frame, bool del=true) |
Remove a frame from the tag. More... | |
void | removeFrames (const ByteVector &id) |
Remove all frames of type id from the tag and free their memory. More... | |
PropertyMap | properties () const |
Implements the unified property interface – export function. More... | |
void | removeUnsupportedProperties (const StringList &properties) |
Removes unsupported frames given by properties. More... | |
PropertyMap | setProperties (const PropertyMap &) |
Implements the unified property interface – import function. More... | |
ByteVector | render () const |
Render the tag back to binary data, suitable to be written to disk. More... | |
ByteVector | render (int version) const |
Render the tag back to binary data, suitable to be written to disk. More... | |
![]() | |
PropertyMap | properties () const |
Exports the tags of the file as dictionary mapping (human readable) tag names (Strings) to StringLists of tag values. More... | |
void | removeUnsupportedProperties (const StringList &properties) |
Removes unsupported properties, or a subset of them, from the tag. More... | |
PropertyMap | setProperties (const PropertyMap &properties) |
Sets the tags of this File to those specified in properties. More... | |
Static Public Member Functions | |
static Latin1StringHandler const * | latin1StringHandler () |
Gets the current string handler that decides how the "Latin-1" data will be converted to and from binary data. More... | |
static void | setLatin1StringHandler (const Latin1StringHandler *handler) |
Sets the string handler that decides how the "Latin-1" data will be converted to and from binary data. More... | |
![]() | |
static void | duplicate (const Tag *source, Tag *target, bool overwrite=true) |
Copies the generic data from one tag to another. More... | |
Protected Member Functions | |
void | read () |
Reads data from the file specified in the constructor. More... | |
void | parse (const ByteVector &data) |
This is called by read to parse the body of the tag. More... | |
void | setTextFrame (const ByteVector &id, const String &value) |
Sets the value of the text frame with the Frame ID id to value. More... | |
void | downgradeFrames (FrameList *existingFrames, FrameList *newFrames) const |
![]() | |
Tag () | |
Construct a Tag. More... | |
The main class in the ID3v2 implementation.
This is the main class in the ID3v2 implementation. It serves two functions. This first, as is obvious from the public API, is to provide a container for the other ID3v2 related classes. In addition, through the read() and parse() protected methods, it provides the most basic level of parsing. In these methods the ID3v2 tag is extracted from the file and split into data components.
ID3v2 tags have several parts, TagLib attempts to provide an interface for them all. header(), footer() and extendedHeader() correspond to those data structures in the ID3v2 standard and the APIs for the classes that they return attempt to reflect this.
Also ID3v2 tags are built up from a list of frames, which are in turn have a header and a list of fields. TagLib provides two ways of accessing the list of frames that are in a given ID3v2 tag. The first is simply via the frameList() method. This is just a list of pointers to the frames. The second is a map from the frame type – i.e. "COMM" for comments – and a list of frames of that type. (In some cases ID3v2 allows for multiple frames of the same type, hence this being a map to a list rather than just a map to an individual frame.)
More information on the structure of frames can be found in the ID3v2::Frame class.
read() and parse() pass binary data to the other ID3v2 class structures, they do not handle parsing of flags or fields, for instance. Those are handled by similar functions within those classes.
TagLib::ID3v2::Tag::Tag | ( | ) |
Constructs an empty ID3v2 tag.
TagLib::ID3v2::Tag::Tag | ( | File * | file, |
long | tagOffset, | ||
const FrameFactory * | factory = FrameFactory::instance() |
||
) |
Constructs an ID3v2 tag read from file starting at tagOffset.
factory specifies which FrameFactory will be used for the construction of new frames.
|
virtual |
Destroys this Tag instance.
Reimplemented from TagLib::Tag.
void TagLib::ID3v2::Tag::addFrame | ( | Frame * | frame | ) |
Add a frame to the tag.
At this point the tag takes ownership of the frame and will handle freeing its memory.
|
virtual |
Returns the album name; if no album name is present in the tag String::null will be returned.
Implements TagLib::Tag.
|
virtual |
Returns the artist name; if no artist name is present in the tag String::null will be returned.
Implements TagLib::Tag.
|
virtual |
Returns the track comment; if no comment is present in the tag String::null will be returned.
Implements TagLib::Tag.
|
protected |
ExtendedHeader* TagLib::ID3v2::Tag::extendedHeader | ( | ) | const |
Returns a pointer to the tag's extended header or null if there is no extended header.
Footer* TagLib::ID3v2::Tag::footer | ( | ) | const |
Returns a pointer to the tag's footer or null if there is no footer.
const FrameList& TagLib::ID3v2::Tag::frameList | ( | ) | const |
Returns a reference to the frame list.
This is an FrameList of all of the frames in the tag in the order that they were parsed.
This can be useful if for example you want iterate over the tag's frames in the order that they occur in the tag.
const FrameList& TagLib::ID3v2::Tag::frameList | ( | const ByteVector & | frameID | ) | const |
Returns the frame list for frames with the id frameID or an empty list if there are no frames of that type.
This is just a convenience and is equivalent to:
const FrameListMap& TagLib::ID3v2::Tag::frameListMap | ( | ) | const |
Returns a reference to the frame list map.
This is an FrameListMap of all of the frames in the tag.
This is the most convenient structure for accessing the tag's frames. Many frame types allow multiple instances of the same frame type so this is a map of lists. In most cases however there will only be a single frame of a certain type.
Let's say for instance that you wanted to access the frame for total beats per minute – the TBPM frame.
|
virtual |
Returns the genre name; if no genre is present in the tag String::null will be returned.
Implements TagLib::Tag.
Header* TagLib::ID3v2::Tag::header | ( | ) | const |
Returns a pointer to the tag's header.
|
virtual |
Returns true if the tag does not contain any data.
This should be reimplemented in subclasses that provide more than the basic tagging abilities in this class.
Reimplemented from TagLib::Tag.
|
static |
Gets the current string handler that decides how the "Latin-1" data will be converted to and from binary data.
|
protected |
This is called by read to parse the body of the tag.
It determines if an extended header exists and adds frames to the FrameListMap.
PropertyMap TagLib::ID3v2::Tag::properties | ( | ) | const |
Implements the unified property interface – export function.
This function does some work to translate the hard-specified ID3v2 frame types into a free-form string-to-stringlist PropertyMap:
|
protected |
Reads data from the file specified in the constructor.
It does basic parsing of the data in the largest chunks. It partitions the tag into the Header, the body of the tag (which contains the ExtendedHeader and frames) and Footer.
void TagLib::ID3v2::Tag::removeFrame | ( | Frame * | frame, |
bool | del = true |
||
) |
Remove a frame from the tag.
If del is true the frame's memory will be freed; if it is false, it must be deleted by the user.
void TagLib::ID3v2::Tag::removeFrames | ( | const ByteVector & | id | ) |
Remove all frames of type id from the tag and free their memory.
void TagLib::ID3v2::Tag::removeUnsupportedProperties | ( | const StringList & | properties | ) |
Removes unsupported frames given by properties.
The elements of properties must be taken from properties().unsupportedData(); they are of one of the following forms:
ByteVector TagLib::ID3v2::Tag::render | ( | ) | const |
Render the tag back to binary data, suitable to be written to disk.
ByteVector TagLib::ID3v2::Tag::render | ( | int | version | ) | const |
Render the tag back to binary data, suitable to be written to disk.
The version parameter specifies the version of the rendered ID3v2 tag. It can be either 4 or 3.
|
virtual |
|
virtual |
|
virtual |
Sets the comment to s.
If s is String::null then this value will be cleared.
Implements TagLib::Tag.
|
virtual |
Sets the genre to s.
If s is String::null then this value will be cleared. For tag formats that use a fixed set of genres, the appropriate value will be selected based on a string comparison. A list of available genres for those formats should be available in that type's implementation.
Implements TagLib::Tag.
|
static |
Sets the string handler that decides how the "Latin-1" data will be converted to and from binary data.
If the parameter handler is null, the previous handler is released and default ISO-8859-1 handler is restored.
PropertyMap TagLib::ID3v2::Tag::setProperties | ( | const PropertyMap & | ) |
Implements the unified property interface – import function.
See the comments in properties().
|
protected |
Sets the value of the text frame with the Frame ID id to value.
If the frame does not exist, it is created.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Returns the track name; if no track name is present in the tag String::null will be returned.
Implements TagLib::Tag.
|
virtual |
Returns the track number; if there is no track number set, this will return 0.
Implements TagLib::Tag.
|
virtual |
Returns the year; if there is no year set, this will return 0.
Implements TagLib::Tag.