Tag Parser 12.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
abstractcontainer.cpp
Go to the documentation of this file.
2#include "./diagnostics.h"
3
4using namespace std;
5using namespace CppUtilities;
6
7namespace TagParser {
8
11
20AbstractContainer::AbstractContainer(iostream &stream, std::uint64_t startOffset)
21 : m_version(0)
22 , m_readVersion(0)
23 , m_doctypeVersion(0)
24 , m_doctypeReadVersion(0)
25 , m_timeScale(0)
26 , m_headerParsed(false)
27 , m_tagsParsed(false)
28 , m_tracksParsed(false)
29 , m_tracksAltered(false)
30 , m_chaptersParsed(false)
31 , m_attachmentsParsed(false)
32 , m_startOffset(startOffset)
33 , m_stream(&stream)
34 , m_reader(BinaryReader(m_stream))
35 , m_writer(BinaryWriter(m_stream))
36{
37}
38
46{
47}
48
59{
60 if (!isHeaderParsed()) {
63 internalParseHeader(diag, progress);
64 m_headerParsed = true;
65 }
66}
67
86{
87 if (!areTagsParsed()) {
88 parseHeader(diag, progress);
89 internalParseTags(diag, progress);
90 m_tagsParsed = true;
91 }
92}
93
110{
111 if (!areTracksParsed()) {
112 parseHeader(diag, progress);
113 internalParseTracks(diag, progress);
114 m_tracksParsed = true;
115 m_tracksAltered = false;
116 }
117}
118
130{
131 if (!areChaptersParsed()) {
132 parseHeader(diag, progress);
133 internalParseChapters(diag, progress);
134 m_chaptersParsed = true;
135 }
136}
137
149{
150 if (!areAttachmentsParsed()) {
151 parseHeader(diag, progress);
152 internalParseAttachments(diag, progress);
153 m_attachmentsParsed = true;
154 }
155}
156
165{
166 internalMakeFile(diag, progress);
167}
168
173{
174 return false;
175}
176
187{
188 CPP_UTILITIES_UNUSED(diag);
190}
191
201{
202 CPP_UTILITIES_UNUSED(diag);
203 CPP_UTILITIES_UNUSED(progress);
205}
206
216{
217 CPP_UTILITIES_UNUSED(diag);
218 CPP_UTILITIES_UNUSED(progress);
220}
221
231{
232 CPP_UTILITIES_UNUSED(diag);
233 CPP_UTILITIES_UNUSED(progress);
235}
236
246{
247 CPP_UTILITIES_UNUSED(diag);
248 CPP_UTILITIES_UNUSED(progress);
250}
251
261{
262 CPP_UTILITIES_UNUSED(diag);
263 CPP_UTILITIES_UNUSED(progress);
265}
266
276{
277 CPP_UTILITIES_UNUSED(diag);
278 CPP_UTILITIES_UNUSED(progress);
280}
281
293{
294 return nullptr;
295}
296
303{
304 CPP_UTILITIES_UNUSED(index);
305 return nullptr;
306}
307
314{
315 return 0;
316}
317
332{
333 CPP_UTILITIES_UNUSED(tag);
334 return false;
335}
336
348{
349}
350
361{
362 CPP_UTILITIES_UNUSED(diag);
364}
365
372{
373 CPP_UTILITIES_UNUSED(index);
374 return nullptr;
375}
376
381{
382 return 0;
383}
384
400{
401 CPP_UTILITIES_UNUSED(track);
402 return false;
403}
404
419{
420}
421
428{
429 CPP_UTILITIES_UNUSED(index);
430 return nullptr;
431}
432
437{
438 return 0;
439}
440
447{
448 return nullptr;
449}
450
457{
458 CPP_UTILITIES_UNUSED(index);
459 return nullptr;
460}
461
466{
467 return 0;
468}
469
474{
475 return false;
476}
477
482{
483 return 1;
484}
485
490{
491 m_headerParsed = false;
492 m_tagsParsed = false;
493 m_tracksParsed = false;
494 m_tracksAltered = false;
495 m_chaptersParsed = false;
496 m_attachmentsParsed = false;
497 m_version = 0;
498 m_readVersion = 0;
501 m_timeScale = 0;
502 m_titles.clear();
503}
504
505} // namespace TagParser
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
The AbstractAttachment class parses and stores attachment information.
The AbstractChapter class parses chapter information.
virtual bool removeTrack(AbstractTrack *track)
Removes the specified track to the container.
bool areAttachmentsParsed() const
Returns an indication whether the attachments have been parsed yet.
virtual void removeAllTags()
Removes all tags attached to the container.
virtual void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to make the file.
virtual void internalParseAttachments(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to parse the attachments.
std::vector< std::string > m_titles
void parseTracks(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the tracks of the file if not parsed yet.
virtual Tag * tag(std::size_t index)
Returns the tag with the specified index.
virtual ~AbstractContainer()
Destroys the container.
bool areTracksParsed() const
Returns an indication whether the tracks have been parsed yet.
virtual std::size_t segmentCount() const
Returns the number of segments.
virtual std::size_t attachmentCount() const
Returns the number of attachments the container holds.
virtual bool supportsTrackModifications() const
Returns whether the implementation supports adding or removing of tracks.
virtual AbstractChapter * chapter(std::size_t index)
Returns the chapter with the specified index.
bool isHeaderParsed() const
Returns an indication whether the header has been parsed yet.
virtual void reset()
Discards all parsing results.
void makeFile(Diagnostics &diag, AbortableProgressFeedback &progress)
Rewrites the file to apply changed tag information.
void parseChapters(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the chapters of the file if not parsed yet.
virtual void internalParseChapters(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to parse the chapters.
virtual AbstractAttachment * createAttachment()
Creates and returns a new attachment.
virtual bool removeTag(Tag *tag)
Removes the specified tag from the container.
void parseHeader(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the header if not parsed yet.
virtual ElementPosition determineTagPosition(Diagnostics &diag) const
Determines the position of the tags inside the file.
virtual AbstractTrack * track(std::size_t index)
Returns the track with the specified index.
virtual ElementPosition determineIndexPosition(Diagnostics &diag) const
Determines the position of the index.
virtual Tag * createTag(const TagTarget &target=TagTarget())
Creates and returns a tag for the specified target.
virtual void internalParseTags(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to parse the tags.
virtual std::size_t tagCount() const
Returns the number of tags attached to the container.
bool areTagsParsed() const
Returns an indication whether the tags have been parsed yet.
bool areChaptersParsed() const
Returns an indication whether the chapters have been parsed yet.
virtual std::size_t trackCount() const
Returns the number of tracks the container holds.
virtual bool supportsTitle() const
Returns whether the title property is supported.
void parseAttachments(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the attachments of the file if not parsed yet.
virtual std::size_t chapterCount() const
Returns the number of chapters the container holds.
AbstractContainer(std::iostream &stream, std::uint64_t startOffset)
Constructs a new container for the specified file stream at the specified startOffset.
virtual void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to parse the header.
void parseTags(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the tag information if not parsed yet.
virtual AbstractAttachment * attachment(std::size_t index)
Returns the attachment with the specified index.
virtual void removeAllTracks()
Removes all tracks from the container.
virtual void internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to parse the tracks.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
The Diagnostics class is a container for DiagMessage.
This exception is thrown when the an operation is invoked that has not been implemented yet.
Definition exceptions.h:60
The TagTarget class specifies the target of a tag.
Definition tagtarget.h:20
The Tag class is used to store, read and write tag information.
Definition tag.h:166
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
ElementPosition
Definition settings.h:13
The AbstractContainerPrivate struct contains private fields of the AbstractContainer class.