Tag Parser  7.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
abstractcontainer.cpp
Go to the documentation of this file.
1 #include "./abstractcontainer.h"
2 #include "./diagnostics.h"
3 
4 using namespace std;
5 using namespace ChronoUtilities;
6 using namespace ConversionUtilities;
7 using namespace IoUtilities;
8 
9 namespace TagParser {
10 
19 AbstractContainer::AbstractContainer(iostream &stream, uint64 startOffset)
20  : m_version(0)
21  , m_readVersion(0)
22  , m_doctypeVersion(0)
23  , m_doctypeReadVersion(0)
24  , m_timeScale(0)
25  , m_headerParsed(false)
26  , m_tagsParsed(false)
27  , m_tracksParsed(false)
28  , m_tracksAltered(false)
29  , m_chaptersParsed(false)
30  , m_attachmentsParsed(false)
31  , m_startOffset(startOffset)
32  , m_stream(&stream)
33  , m_reader(BinaryReader(m_stream))
34  , m_writer(BinaryWriter(m_stream))
35 {
36 }
37 
45 {
46 }
47 
58 {
59  if (!isHeaderParsed()) {
60  removeAllTags();
62  internalParseHeader(diag);
63  m_headerParsed = true;
64  }
65 }
66 
85 {
86  if (!areTagsParsed()) {
87  parseHeader(diag);
88  internalParseTags(diag);
89  m_tagsParsed = true;
90  }
91 }
92 
109 {
110  if (!areTracksParsed()) {
111  parseHeader(diag);
112  internalParseTracks(diag);
113  m_tracksParsed = true;
114  m_tracksAltered = false;
115  }
116 }
117 
129 {
130  if (!areChaptersParsed()) {
131  parseHeader(diag);
132  internalParseChapters(diag);
133  m_chaptersParsed = true;
134  }
135 }
136 
148 {
149  if (!areAttachmentsParsed()) {
150  parseHeader(diag);
152  m_attachmentsParsed = true;
153  }
154 }
155 
164 {
165  internalMakeFile(diag, progress);
166 }
167 
172 {
173  return false;
174 }
175 
186 {
187  VAR_UNUSED(diag);
188  return ElementPosition::Keep;
189 }
190 
200 {
201  VAR_UNUSED(diag);
202  throw NotImplementedException();
203 }
204 
214 {
215  VAR_UNUSED(diag);
216  throw NotImplementedException();
217 }
218 
228 {
229  VAR_UNUSED(diag);
230  throw NotImplementedException();
231 }
232 
242 {
243  VAR_UNUSED(diag);
244  throw NotImplementedException();
245 }
246 
256 {
257  VAR_UNUSED(diag);
258  throw NotImplementedException();
259 }
260 
270 {
271  VAR_UNUSED(diag);
272  VAR_UNUSED(progress);
273  throw NotImplementedException();
274 }
275 
287 {
288  return nullptr;
289 }
290 
297 {
298  VAR_UNUSED(index);
299  return nullptr;
300 }
301 
308 {
309  return 0;
310 }
311 
326 {
327  VAR_UNUSED(tag);
328  return false;
329 }
330 
342 {
343 }
344 
355 {
356  VAR_UNUSED(diag);
357  return ElementPosition::Keep;
358 }
359 
366 {
367  VAR_UNUSED(index);
368  return nullptr;
369 }
370 
375 {
376  return 0;
377 }
378 
394 {
395  VAR_UNUSED(track);
396  return false;
397 }
398 
413 {
414 }
415 
422 {
423  VAR_UNUSED(index);
424  return nullptr;
425 }
426 
431 {
432  return 0;
433 }
434 
441 {
442  return nullptr;
443 }
444 
451 {
452  VAR_UNUSED(index);
453  return nullptr;
454 }
455 
460 {
461  return 0;
462 }
463 
468 {
469  return false;
470 }
471 
476 {
477  return 1;
478 }
479 
484 {
485  m_headerParsed = false;
486  m_tagsParsed = false;
487  m_tracksParsed = false;
488  m_tracksAltered = false;
489  m_chaptersParsed = false;
490  m_attachmentsParsed = false;
491  m_version = 0;
492  m_readVersion = 0;
493  m_doctypeVersion = 0;
495  m_timeScale = 0;
496  m_titles.clear();
497 }
498 
499 } // namespace TagParser
This exception is thrown when the an operation is invoked that has not been implemented yet...
Definition: exceptions.h:53
virtual ElementPosition determineTagPosition(Diagnostics &diag) const
Determines the position of the tags inside the file.
The Tag class is used to store, read and write tag information.
Definition: tag.h:95
virtual AbstractAttachment * createAttachment()
Creates and returns a new attachment.
virtual AbstractAttachment * attachment(std::size_t index)
Returns the attachment with the specified index.
virtual ElementPosition determineIndexPosition(Diagnostics &diag) const
Determines the position of the index.
virtual bool removeTag(Tag *tag)
Removes the specified tag from the container.
virtual void removeAllTracks()
Removes all tracks from the container.
STL namespace.
virtual std::size_t attachmentCount() const
Returns the number of attachments the container holds.
virtual void internalMakeFile(Diagnostics &diag, AbortableProgressFeedback &progress)
Internally called to make the file.
virtual Tag * tag(std::size_t index)
Returns the tag with the specified index.
virtual std::size_t chapterCount() const
Returns the number of chapters the container holds.
virtual Tag * createTag(const TagTarget &target=TagTarget())
Creates and returns a tag for the specified target.
virtual void reset()
Discards all parsing results.
void parseTracks(Diagnostics &diag)
Parses the tracks of the file if not parsed yet.
bool areChaptersParsed() const
Returns an indication whether the chapters have been parsed yet.
virtual bool supportsTrackModifications() const
Returns whether the implementation supports adding or removing of tracks.
virtual std::size_t trackCount() const
Returns the number of tracks the container holds.
bool isHeaderParsed() const
Returns an indication whether the header has been parsed yet.
void parseAttachments(Diagnostics &diag)
Parses the attachments of the file if not parsed yet.
virtual void removeAllTags()
Removes all tags attached to the container.
virtual void internalParseTracks(Diagnostics &diag)
Internally called to parse the tracks.
virtual void internalParseTags(Diagnostics &diag)
Internally called to parse the tags.
Contains utility classes helping to read and write streams.
bool areAttachmentsParsed() const
Returns an indication whether the attachments have been parsed yet.
void makeFile(Diagnostics &diag, AbortableProgressFeedback &progress)
Rewrites the file to apply changed tag information.
virtual ~AbstractContainer()
Destroys the container.
virtual void internalParseAttachments(Diagnostics &diag)
Internally called to parse the attachments.
The TagTarget class specifies the target of a tag.
Definition: tagtarget.h:21
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks...
virtual void internalParseChapters(Diagnostics &diag)
Internally called to parse the chapters.
std::vector< std::string > m_titles
bool areTracksParsed() const
Returns an indication whether the tracks have been parsed yet.
virtual bool supportsTitle() const
Returns whether the title property is supported.
virtual AbstractTrack * track(std::size_t index)
Returns the track with the specified index.
virtual std::size_t segmentCount() const
Returns the number of segments.
virtual AbstractChapter * chapter(std::size_t index)
Returns the chapter with the specified index.
void parseChapters(Diagnostics &diag)
Parses the chapters of the file if not parsed yet.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
Definition: abstracttrack.h:39
The AbstractChapter class parses chapter information.
virtual bool removeTrack(AbstractTrack *track)
Removes the specified track to the container.
void parseHeader(Diagnostics &diag)
Parses the header if not parsed yet.
bool areTagsParsed() const
Returns an indication whether the tags have been parsed yet.
virtual void internalParseHeader(Diagnostics &diag)
Internally called to parse the header.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
The AbstractAttachment class parses and stores attachment information.
virtual std::size_t tagCount() const
Returns the number of tags attached to the container.
ElementPosition
Definition: settings.h:10
void parseTags(Diagnostics &diag)
Parses the tag information if not parsed yet.
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:154