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 TextImplicit,
146 Text
147 };
148
151
157
162
171
178
187
188 // Functions used by parseItem() to create items from atom data.
189 static MP4::AtomDataList parseData2(
190 const MP4::Atom *atom, const ByteVector &data, int expectedFlags = -1,
191 bool freeForm = false);
193 const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags = -1,
194 bool freeForm = false);
195 static std::pair<String, Item> parseText(
196 const MP4::Atom *atom, const ByteVector &bytes, int expectedFlags = 1);
197 static std::pair<String, Item> parseFreeForm(
198 const MP4::Atom *atom, const ByteVector &bytes);
199 static std::pair<String, Item> parseInt(
200 const MP4::Atom *atom, const ByteVector &bytes);
201 static std::pair<String, Item> parseByte(
202 const MP4::Atom *atom, const ByteVector &bytes);
203 static std::pair<String, Item> parseTextOrInt(
204 const MP4::Atom *atom, const ByteVector &bytes);
205 static std::pair<String, Item> parseUInt(
206 const MP4::Atom *atom, const ByteVector &bytes);
207 static std::pair<String, Item> parseLongLong(
208 const MP4::Atom *atom, const ByteVector &bytes);
209 static std::pair<String, Item> parseGnre(
210 const MP4::Atom *atom, const ByteVector &bytes);
211 static std::pair<String, Item> parseIntPair(
212 const MP4::Atom *atom, const ByteVector &bytes);
213 static std::pair<String, Item> parseBool(
214 const MP4::Atom *atom, const ByteVector &bytes);
215 static std::pair<String, Item> parseCovr(
216 const MP4::Atom *atom, const ByteVector &data);
217
218 // Functions used by renderItem() to render atom data for items.
220 const ByteVector &name, const ByteVector &data);
222 const ByteVector &name, int flags, const ByteVectorList &data);
224 const ByteVector &name, const MP4::Item &item, int flags = TypeUTF8);
226 const String &name, const MP4::Item &item);
228 const ByteVector &name, const MP4::Item &item);
230 const ByteVector &name, const MP4::Item &item);
232 const ByteVector &name, const MP4::Item &item);
234 const ByteVector &name, const MP4::Item &item);
236 const ByteVector &name, const MP4::Item &item);
238 const ByteVector &name, const MP4::Item &item);
240 const ByteVector &name, const MP4::Item &item);
242 const ByteVector &name, const MP4::Item &item);
244 const ByteVector &name, const MP4::Item &item);
245
246 private:
247 static ItemFactory factory;
248
249 class ItemFactoryPrivate;
251 std::unique_ptr<ItemFactoryPrivate> d;
252 };
253
254 } // namespace MP4
255} // namespace TagLib
256
257#endif
A list of ByteVectors.
Definition: tbytevectorlist.h:42
A byte vector.
Definition: tbytevector.h:46
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 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)
virtual std::pair< String, Item > parseItem(const Atom *atom, const ByteVector &data) const
MP4 item.
Definition: mp4item.h:37
A generic, implicitly shared map.
Definition: tmap.h:45
A list of strings.
Definition: tstringlist.h:44
A wide string class suitable for unicode.
Definition: tstring.h:83
@ TypeUTF8
Definition: mp4atom.h:39
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