Tag Parser  6.2.1
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 
3 using namespace std;
4 using namespace ChronoUtilities;
5 using namespace ConversionUtilities;
6 using namespace IoUtilities;
7 
8 namespace Media {
9 
18 AbstractContainer::AbstractContainer(iostream &stream, uint64 startOffset) :
19  m_version(0),
20  m_readVersion(0),
21  m_doctypeVersion(0),
22  m_doctypeReadVersion(0),
23  m_timeScale(0),
24  m_headerParsed(false),
25  m_tagsParsed(false),
26  m_tracksParsed(false),
27  m_tracksAltered(false),
28  m_chaptersParsed(false),
29  m_attachmentsParsed(false),
30  m_startOffset(startOffset),
31  m_stream(&stream),
32  m_reader(BinaryReader(m_stream)),
33  m_writer(BinaryWriter(m_stream))
34 {}
35 
43 {}
44 
55 {
56  if(!isHeaderParsed()) {
58  removeAllTags();
61  m_headerParsed = true;
62  }
63 }
64 
83 {
84  if(!areTagsParsed()) {
85  parseHeader();
87  m_tagsParsed = true;
88  }
89 }
90 
107 {
108  if(!areTracksParsed()) {
109  parseHeader();
111  m_tracksParsed = true;
112  m_tracksAltered = false;
113  }
114 }
115 
127 {
128  if(!areChaptersParsed()) {
129  parseHeader();
131  m_chaptersParsed = true;
132  }
133 }
134 
146 {
147  if(!areAttachmentsParsed()) {
148  parseHeader();
150  m_attachmentsParsed = true;
151  }
152 }
153 
162 {
164 }
165 
170 {
171  return false;
172 }
173 
183 {
184  return ElementPosition::Keep;
185 }
186 
196 {
197  throw NotImplementedException();
198 }
199 
209 {
210  throw NotImplementedException();
211 }
212 
222 {
223  throw NotImplementedException();
224 }
225 
235 {
236  throw NotImplementedException();
237 }
238 
248 {
249  throw NotImplementedException();
250 }
251 
261 {
262  throw NotImplementedException();
263 }
264 
276 {
277  return nullptr;
278 }
279 
286 {
287  return nullptr;
288 }
289 
296 {
297  return 0;
298 }
299 
314 {
315  return false;
316 }
317 
329 {}
330 
340 {
341  return ElementPosition::Keep;
342 }
343 
350 {
351  return nullptr;
352 }
353 
358 {
359  return 0;
360 }
361 
377 {
378  return false;
379 }
380 
395 {}
396 
403 {
404  return nullptr;
405 }
406 
411 {
412  return 0;
413 }
414 
421 {
422  return nullptr;
423 }
424 
431 {
432  return nullptr;
433 }
434 
439 {
440  return 0;
441 }
442 
447 {
448  return false;
449 }
450 
455 {
456  return 1;
457 }
458 
463 {
464  m_headerParsed = false;
465  m_tagsParsed = false;
466  m_tracksParsed = false;
467  m_tracksAltered = false;
468  m_chaptersParsed = false;
469  m_attachmentsParsed = false;
470  m_version = 0;
471  m_readVersion = 0;
472  m_doctypeVersion = 0;
474  m_timeScale = 0;
475  m_titles.clear();
476 }
477 
478 } // namespace Media
virtual bool supportsTitle() const
Returns whether the title property is supported.
virtual std::size_t trackCount() const
Returns the number of tracks the container holds.
void invalidateStatus()
Invalidates the current status.
virtual void removeAllTags()
Removes all tags attached to the container.
This exception is thrown when the an operation is invoked that has not been implemented yet...
Definition: exceptions.h:59
virtual bool removeTag(Tag *tag)
Removes the specified tag from the container.
void parseAttachments()
Parses the attachments of the file if not parsed yet.
virtual AbstractAttachment * attachment(std::size_t index)
Returns the attachment with the specified index.
The AbstractChapter class parses chapter information.
virtual Tag * createTag(const TagTarget &target=TagTarget())
Creates and returns a tag for the specified target.
virtual std::size_t chapterCount() const
Returns the number of chapters the container holds.
virtual AbstractChapter * chapter(std::size_t index)
Returns the chapter with the specified index.
virtual void internalParseChapters()
Internally called to parse the chapters.
virtual std::size_t segmentCount() const
Returns the number of segments.
void makeFile()
Rewrites the file to apply changed tag information.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
Definition: abstracttrack.h:40
virtual void internalParseTags()
Internally called to parse the tags.
STL namespace.
bool areChaptersParsed() const
Returns an indication whether the chapters have been parsed yet.
virtual ElementPosition determineTagPosition() const
Determines the position of the tags inside the file.
virtual void internalParseAttachments()
Internally called to parse the attachments.
virtual void removeAllTracks()
Removes all tracks from the container.
virtual std::size_t attachmentCount() const
Returns the number of attachments the container holds.
bool areTracksParsed() const
Returns an indication whether the tracks have been parsed yet.
virtual void internalMakeFile()
Internally called to make the file.
void parseChapters()
Parses the chapters of the file if not parsed yet.
Contains utility classes helping to read and write streams.
The AbstractAttachment class parses and stores attachment information.
void parseTags()
Parses the tag information if not parsed yet.
virtual std::size_t tagCount() const
Returns the number of tags attached to the container.
bool isHeaderParsed() const
Returns an indication whether the header has been parsed yet.
void parseHeader()
Parses the header if not parsed yet.
bool areAttachmentsParsed() const
Returns an indication whether the attachments have been parsed yet.
The Tag class is used to store, read and write tag information.
Definition: tag.h:98
bool areTagsParsed() const
Returns an indication whether the tags have been parsed yet.
virtual ~AbstractContainer()
Destroys the container.
virtual bool supportsTrackModifications() const
Returns whether the implementation supports adding or removing of tracks.
virtual void reset()
Discards all parsing results.
std::vector< std::string > m_titles
virtual void internalParseHeader()
Internally called to parse the header.
virtual void internalParseTracks()
Internally called to parse the tracks.
virtual AbstractTrack * track(std::size_t index)
Returns the track with the specified index.
virtual AbstractAttachment * createAttachment()
Creates and returns a new attachment.
The TagTarget class specifies the target of a tag.
Definition: tagtarget.h:31
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
void parseTracks()
Parses the tracks of the file if not parsed yet.
virtual bool removeTrack(AbstractTrack *track)
Removes the specified track to the container.
virtual ElementPosition determineIndexPosition() const
Determines the position of the index.
virtual Tag * tag(std::size_t index)
Returns the tag with the specified index.