| TagLib 1.13 |  |

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
TagLib::ID3v2::FrameFactory Class Reference

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

`#include <id3v2framefactory.h>`

## Public Member Functions
TAGLIB_DEPRECATED Frame * | createFrame (const ByteVector &data, bool synchSafeInts) const
TAGLIB_DEPRECATED Frame * | createFrame (const ByteVector &data, unsigned int version=4) const
Frame * | createFrame (const ByteVector &data, Header *tagHeader) const
Frame * | createFrame (const ByteVector &data, const Header *tagHeader) const
void | rebuildAggregateFrames (ID3v2::Tag *tag) const
String::Type | defaultTextEncoding () const
void | setDefaultTextEncoding (String::Type encoding)

## Static Public Member Functions
static FrameFactory * | instance ()

## 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 and reimplement createFrame(). Then by setting your factory to be the default factory in ID3v2::Tag constructor 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

## ◆ FrameFactory()

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

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

## ◆ ~FrameFactory()

virtual TagLib::ID3v2::FrameFactory::~FrameFactory | ( |  | ) |
| protected virtual

Destroys the frame factory.

## Member Function Documentation

## ◆ createFrame() [1/4]

TAGLIB_DEPRECATED 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.

Deprecated:
  Please use the method below that accepts a ID3v2::Header instance in new code.

## ◆ createFrame() [2/4]

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

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

## ◆ createFrame() [3/4]

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

Deprecated:
  Use createFrame(const ByteVector &, const Header *) const.

## ◆ createFrame() [4/4]

TAGLIB_DEPRECATED Frame * TagLib::ID3v2::FrameFactory::createFrame | ( | const ByteVector & | data,
|  | unsigned int | 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.

Deprecated:
  Please use the method below that accepts a ID3v2::Header instance in new code.

## ◆ defaultTextEncoding()

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 explicitly set differently for the individual frame) when being rendered.

See also
  setDefaultTextEncoding()

## ◆ instance()

static FrameFactory * TagLib::ID3v2::FrameFactory::instance | ( |  | ) |
| static

## ◆ rebuildAggregateFrames()

void TagLib::ID3v2::FrameFactory::rebuildAggregateFrames | ( | ID3v2::Tag * | tag | ) | const

After a tag has been read, this tries to rebuild some of them information, most notably the recording date, from frames that have been deprecated and can't be upgraded directly.

## ◆ setDefaultTextEncoding()

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()

## ◆ updateFrame()

virtual bool TagLib::ID3v2::FrameFactory::updateFrame | ( | Frame::Header * | header | ) | const
| protected virtual

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:

- id3v2framefactory.h