A factory for creating ID3v2 frames during parsing. More...

#include <id3v2framefactory.h>

Public Member Functions

FramecreateFrame (const ByteVector &data, bool synchSafeInts) const
FramecreateFrame (const ByteVector &data, uint version=4) const
FramecreateFrame (const ByteVector &data, Header *tagHeader) const
String::Type defaultTextEncoding () const
void setDefaultTextEncoding (String::Type encoding)

Static Public Member Functions

static FrameFactoryinstance ()

Protected Member Functions

 FrameFactory ()
virtual ~FrameFactory ()
virtual bool updateFrame (Frame::Header *header) const

Detailed Description

A factory for creating ID3v2 frames during parsing.

This factory abstracts away the frame creation process and instantiates the appropriate ID3v2::Frame subclasses based on the contents of the data.

Reimplementing this factory is the key to adding support for frame types not directly supported by TagLib to your application. To do so you would subclass this factory reimplement createFrame(). Then by setting your factory to be the default factory in ID3v2::Tag constructor or with MPEG::File::setID3v2FrameFactory() you can implement behavior that will allow for new ID3v2::Frame subclasses (also provided by you) to be used.

This implements both abstract factory and singleton patterns of which more information is available on the web and in software design textbooks (Notably Design Patters).

Note
You do not need to use this factory to create new frames to add to an ID3v2::Tag. You can instantiate frame subclasses directly (with new) and add them to a tag using ID3v2::Tag::addFrame()
See Also
ID3v2::Tag::addFrame()

Constructor & Destructor Documentation

TagLib::ID3v2::FrameFactory::FrameFactory ( )
protected

Constructs a frame factory. Because this is a singleton this method is protected, but may be used for subclasses.

virtual TagLib::ID3v2::FrameFactory::~FrameFactory ( )
protectedvirtual

Destroys the frame factory.

Member Function Documentation

Frame* TagLib::ID3v2::FrameFactory::createFrame ( const ByteVector data,
bool  synchSafeInts 
) const

Create a frame based on data. synchSafeInts should only be set false if we are parsing an old tag (v2.3 or older) that does not support synchsafe ints.

Frame* TagLib::ID3v2::FrameFactory::createFrame ( const ByteVector data,
uint  version = 4 
) const

Create a frame based on data. version should indicate the ID3v2 version of the tag. As ID3v2.4 is the most current version of the standard 4 is the default.

Frame* TagLib::ID3v2::FrameFactory::createFrame ( const ByteVector data,
Header tagHeader 
) const

Create a frame based on data. tagHeader should be a valid ID3v2::Header instance.

String::Type TagLib::ID3v2::FrameFactory::defaultTextEncoding ( ) const

Returns the default text encoding for text frames. If setTextEncoding() has not been explicitly called this will only be used for new text frames. However, if this value has been set explicitly all frames will be converted to this type (unless it's explitly set differently for the individual frame) when being rendered.

See Also
setDefaultTextEncoding()
static FrameFactory* TagLib::ID3v2::FrameFactory::instance ( )
static
void TagLib::ID3v2::FrameFactory::setDefaultTextEncoding ( String::Type  encoding)

Set the default text encoding for all text frames that are created to encoding. If no value is set the frames with either default to the encoding type that was parsed and new frames default to Latin1.

Valid string types for ID3v2 tags are Latin1, UTF8, UTF16 and UTF16BE.

See Also
defaultTextEncoding()
virtual bool TagLib::ID3v2::FrameFactory::updateFrame ( Frame::Header header) const
protectedvirtual

This method checks for compliance to the current ID3v2 standard (2.4) and does nothing in the common case. However if a frame is found that is not compatible with the current standard, this method either updates the frame or indicates that it should be discarded.

This method with return true (with or without changes to the frame) if this frame should be kept or false if it should be discarded.

See the id3v2.4.0-changes.txt document for further information.


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