TagLib API Documentation
mp4itemfactory.h
Go to the documentation of this file.
1/***************************************************************************
2 copyright : (C) 2023 by Urs Fleisch
3 email : ufleisch@users.sourceforge.net
4 ***************************************************************************/
5
6/***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26#ifndef TAGLIB_MP4ITEMFACTORY_H
27#define TAGLIB_MP4ITEMFACTORY_H
28
29#include <memory>
30#include "taglib_export.h"
31#include "mp4item.h"
32
33namespace TagLib {
34
35 namespace MP4 {
36
38
70 {
71 public:
72 ItemFactory(const ItemFactory &) = delete;
73 ItemFactory &operator=(const ItemFactory &) = delete;
74
76
83 virtual std::pair<String, Item> parseItem(
84 const Atom *atom, const ByteVector &data) const;
85
92 const String &itemName, const Item &item) const;
93
99 virtual std::pair<ByteVector, Item> itemFromProperty(
100 const String &key, const StringList &values) const;
101
108 virtual std::pair<String, StringList> itemToProperty(
109 const ByteVector &itemName, const Item &item) const;
110
117 virtual String propertyKeyForName(const ByteVector &name) const;
118
125 virtual ByteVector nameForPropertyKey(const String &key) const;
126
127 protected:
132 enum class ItemHandlerType {
133 Unknown,
134 FreeForm,
135 IntPair,
136 IntPairNoTrailing,
137 Bool,
138 Int,
139 TextOrInt,
140 UInt,
141 LongLong,
142 Byte,
143 Gnre,
144 Covr,
145 Stem,
146 TextImplicit,
147 Text
148 };
149
152
158
163
172
179
188
189 // Functions used by parseItem() to create items from atom data.
190 static MP4::AtomDataList parseData2(
191 const MP4::Atom *atom, const ByteVector &data, int expectedFlags = -1,
192 bool freeForm = false);
194 const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags = -1,
195 bool freeForm = false);
196 static std::pair<String, Item> parseText(
197 const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags = 1);
198 static std::pair<String, Item> parseFreeForm(
199 const MP4::Atom *atom, const ByteVector &bytes);
200 static std::pair<String, Item> parseInt(
201 const MP4::Atom *atom, const ByteVector &bytes);
202 static std::pair<String, Item> parseByte(
203 const MP4::Atom *atom, const ByteVector &bytes);
204 static std::pair<String, Item> parseTextOrInt(
205 const MP4::Atom *atom, const ByteVector &bytes);
206 static std::pair<String, Item> parseUInt(
207 const MP4::Atom *atom, const ByteVector &bytes);
208 static std::pair<String, Item> parseLongLong(
209 const MP4::Atom *atom, const ByteVector &bytes);
210 static std::pair<String, Item> parseGnre(
211 const MP4::Atom *atom, const ByteVector &bytes);
212 static std::pair<String, Item> parseIntPair(
213 const MP4::Atom *atom, const ByteVector &bytes);
214 static std::pair<String, Item> parseBool(
215 const MP4::Atom *atom, const ByteVector &bytes);
216 static std::pair<String, Item> parseCovr(
217 const MP4::Atom *atom, const ByteVector &data);
218 static std::pair<String, Item> parseStem(
219 const MP4::Atom *atom, const ByteVector &data);
220
221 // Functions used by renderItem() to render atom data for items.
223 const ByteVector &name, const ByteVector &data);
225 const ByteVector &name, int flags, const ByteVectorList &data);
227 const ByteVector &name, const MP4::Item &item, int flags = TypeUTF8);
229 const String &name, const MP4::Item &item);
231 const ByteVector &name, const MP4::Item &item);
233 const ByteVector &name, const MP4::Item &item);
235 const ByteVector &name, const MP4::Item &item);
237 const ByteVector &name, const MP4::Item &item);
239 const ByteVector &name, const MP4::Item &item);
241 const ByteVector &name, const MP4::Item &item);
243 const ByteVector &name, const MP4::Item &item);
245 const ByteVector &name, const MP4::Item &item);
247 const ByteVector &name, const MP4::Item &item);
249 const ByteVector &name, const MP4::Item &item);
250
251 private:
252 static ItemFactory factory;
253
254 class ItemFactoryPrivate;
256 std::unique_ptr<ItemFactoryPrivate> d;
257 };
258
259 } // namespace MP4
260} // namespace TagLib
261
262#endif
A list of ByteVectors.
Definition tbytevectorlist.h:42
A byte vector.
Definition tbytevector.h:46
A generic, implicitly shared list.
Definition tlist.h:54
A factory for creating MP4 items during parsing.
Definition mp4itemfactory.h:70
static ByteVector renderText(const ByteVector &name, const MP4::Item &item, int flags=TypeUTF8)
static ItemFactory * instance()
static std::pair< String, Item > parseUInt(const MP4::Atom *atom, const ByteVector &bytes)
virtual std::pair< String, StringList > itemToProperty(const ByteVector &itemName, const Item &item) const
static std::pair< String, Item > parseTextOrInt(const MP4::Atom *atom, const ByteVector &bytes)
ItemFactory & operator=(const ItemFactory &)=delete
static std::pair< String, Item > parseGnre(const MP4::Atom *atom, const ByteVector &bytes)
static ByteVector renderIntPairNoTrailing(const ByteVector &name, const MP4::Item &item)
static ByteVector renderInt(const ByteVector &name, const MP4::Item &item)
static ByteVector renderByte(const ByteVector &name, const MP4::Item &item)
static std::pair< String, Item > parseFreeForm(const MP4::Atom *atom, const ByteVector &bytes)
static std::pair< String, Item > parseIntPair(const MP4::Atom *atom, const ByteVector &bytes)
virtual ByteVector renderItem(const String &itemName, const Item &item) const
static ByteVector renderLongLong(const ByteVector &name, const MP4::Item &item)
static ByteVectorList parseData(const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags=-1, bool freeForm=false)
virtual ByteVector nameForPropertyKey(const String &key) const
static ByteVector renderBool(const ByteVector &name, const MP4::Item &item)
static ByteVector renderAtom(const ByteVector &name, const ByteVector &data)
static std::pair< String, Item > parseLongLong(const MP4::Atom *atom, const ByteVector &bytes)
static ByteVector renderStem(const ByteVector &name, const MP4::Item &item)
static MP4::AtomDataList parseData2(const MP4::Atom *atom, const ByteVector &data, int expectedFlags=-1, bool freeForm=false)
static ByteVector renderCovr(const ByteVector &name, const MP4::Item &item)
static ByteVector renderTextOrInt(const ByteVector &name, const MP4::Item &item)
virtual ItemHandlerType handlerTypeForName(const ByteVector &name) const
virtual std::pair< ByteVector, Item > itemFromProperty(const String &key, const StringList &values) const
static std::pair< String, Item > parseInt(const MP4::Atom *atom, const ByteVector &bytes)
ItemHandlerType
Definition mp4itemfactory.h:132
static ByteVector renderData(const ByteVector &name, int flags, const ByteVectorList &data)
virtual String propertyKeyForName(const ByteVector &name) const
static std::pair< String, Item > parseBool(const MP4::Atom *atom, const ByteVector &bytes)
static std::pair< String, Item > parseCovr(const MP4::Atom *atom, const ByteVector &data)
static std::pair< String, Item > parseByte(const MP4::Atom *atom, const ByteVector &bytes)
virtual Map< ByteVector, String > namePropertyMap() const
ItemFactory(const ItemFactory &)=delete
static std::pair< String, Item > parseText(const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags=1)
virtual NameHandlerMap nameHandlerMap() const
static ByteVector renderIntPair(const ByteVector &name, const MP4::Item &item)
static ByteVector renderFreeForm(const String &name, const MP4::Item &item)
static ByteVector renderUInt(const ByteVector &name, const MP4::Item &item)
static std::pair< String, Item > parseStem(const MP4::Atom *atom, const ByteVector &data)
virtual std::pair< String, Item > parseItem(const Atom *atom, const ByteVector &data) const
MP4 item.
Definition mp4item.h:38
Definition mp4stem.h:41
A list of strings.
Definition tstringlist.h:44
A wide string class suitable for unicode.
Definition tstring.h:83
A namespace for all TagLib related classes and functions.
Definition apefile.h:41
#define TAGLIB_EXPORT
Definition taglib_export.h:40
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition taglib_export.h:55