Tag Parser 11.5.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
The AbstractContainer class provides an interface and common functionality to parse and make a certain container format. More...
#include <abstractcontainer.h>
Public Member Functions | |
virtual | ~AbstractContainer () |
Destroys the container. More... | |
std::iostream & | stream () |
Returns the related stream. More... | |
void | setStream (std::iostream &stream) |
Sets the related stream. More... | |
std::uint64_t | startOffset () const |
Returns the start offset in the related stream. More... | |
CppUtilities::BinaryReader & | reader () |
Returns the related BinaryReader. More... | |
CppUtilities::BinaryWriter & | writer () |
Returns the related BinaryWriter. More... | |
void | parseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the header if not parsed yet. More... | |
void | parseTags (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the tag information if not parsed yet. More... | |
void | parseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the tracks of the file if not parsed yet. More... | |
void | parseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the chapters of the file if not parsed yet. More... | |
void | parseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the attachments of the file if not parsed yet. More... | |
void | makeFile (Diagnostics &diag, AbortableProgressFeedback &progress) |
Rewrites the file to apply changed tag information. More... | |
bool | isHeaderParsed () const |
Returns an indication whether the header has been parsed yet. More... | |
bool | areTagsParsed () const |
Returns an indication whether the tags have been parsed yet. More... | |
bool | areTracksParsed () const |
Returns an indication whether the tracks have been parsed yet. More... | |
bool | areChaptersParsed () const |
Returns an indication whether the chapters have been parsed yet. More... | |
bool | areAttachmentsParsed () const |
Returns an indication whether the attachments have been parsed yet. More... | |
virtual Tag * | createTag (const TagTarget &target=TagTarget()) |
Creates and returns a tag for the specified target. More... | |
virtual Tag * | tag (std::size_t index) |
Returns the tag with the specified index. More... | |
virtual std::size_t | tagCount () const |
Returns the number of tags attached to the container. More... | |
virtual bool | removeTag (Tag *tag) |
Removes the specified tag from the container. More... | |
virtual void | removeAllTags () |
Removes all tags attached to the container. More... | |
virtual ElementPosition | determineTagPosition (Diagnostics &diag) const |
Determines the position of the tags inside the file. More... | |
virtual AbstractTrack * | track (std::size_t index) |
Returns the track with the specified index. More... | |
virtual std::size_t | trackCount () const |
Returns the number of tracks the container holds. More... | |
virtual bool | removeTrack (AbstractTrack *track) |
Removes the specified track to the container. More... | |
virtual void | removeAllTracks () |
Removes all tracks from the container. More... | |
virtual bool | supportsTrackModifications () const |
Returns whether the implementation supports adding or removing of tracks. More... | |
virtual ElementPosition | determineIndexPosition (Diagnostics &diag) const |
Determines the position of the index. More... | |
virtual AbstractChapter * | chapter (std::size_t index) |
Returns the chapter with the specified index. More... | |
virtual std::size_t | chapterCount () const |
Returns the number of chapters the container holds. More... | |
virtual AbstractAttachment * | createAttachment () |
Creates and returns a new attachment. More... | |
virtual AbstractAttachment * | attachment (std::size_t index) |
Returns the attachment with the specified index. More... | |
virtual std::size_t | attachmentCount () const |
Returns the number of attachments the container holds. More... | |
std::uint64_t | version () const |
Returns the version if known; otherwise returns 0. More... | |
std::uint64_t | readVersion () const |
Returns the "read version" if known; otherwise returns 0. More... | |
const std::string & | documentType () const |
Returns a string that describes the document type if available; otherwise returns an empty string. More... | |
std::uint64_t | doctypeVersion () const |
Returns the document type version if known; otherwise returns 0. More... | |
std::uint64_t | doctypeReadVersion () const |
Returns the document type "read version" if known; otherwise returns 0. More... | |
const std::vector< std::string > & | titles () const |
Returns the title(s) of the file. More... | |
void | setTitle (std::string_view title, std::size_t segmentIndex=0) |
Sets the title for the specified segment. More... | |
virtual bool | supportsTitle () const |
Returns whether the title property is supported. More... | |
virtual std::size_t | segmentCount () const |
Returns the number of segments. More... | |
CppUtilities::TimeSpan | duration () const |
Returns the duration of the file if known; otherwise returns a time span of zero ticks. More... | |
CppUtilities::DateTime | creationTime () const |
Returns the creation time of the file if known; otherwise the returned date time is null. More... | |
CppUtilities::DateTime | modificationTime () const |
Returns the modification time of the file if known; otherwise the returned date time is null. More... | |
std::uint32_t | timeScale () const |
Returns the time scale of the file if known; otherwise returns 0. More... | |
virtual void | reset () |
Discards all parsing results. More... | |
Protected Member Functions | |
AbstractContainer (std::iostream &stream, std::uint64_t startOffset) | |
Constructs a new container for the specified file stream at the specified startOffset. More... | |
virtual void | internalParseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the header. More... | |
virtual void | internalParseTags (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the tags. More... | |
virtual void | internalParseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the tracks. More... | |
virtual void | internalParseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the chapters. More... | |
virtual void | internalParseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the attachments. More... | |
virtual void | internalMakeFile (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to make the file. More... | |
Protected Attributes | |
std::uint64_t | m_version |
std::uint64_t | m_readVersion |
std::string | m_doctype |
std::uint64_t | m_doctypeVersion |
std::uint64_t | m_doctypeReadVersion |
std::vector< std::string > | m_titles |
CppUtilities::TimeSpan | m_duration |
CppUtilities::DateTime | m_creationTime |
CppUtilities::DateTime | m_modificationTime |
std::uint32_t | m_timeScale |
bool | m_headerParsed |
bool | m_tagsParsed |
bool | m_tracksParsed |
bool | m_tracksAltered |
bool | m_chaptersParsed |
bool | m_attachmentsParsed |
The AbstractContainer class provides an interface and common functionality to parse and make a certain container format.
Definition at line 29 of file abstractcontainer.h.
|
virtual |
Destroys the container.
Destroys the reader, the writer and track, tag, chapter and attachment objects as well. Does NOT destroy the stream which has been specified when constructing the object.
Definition at line 42 of file abstractcontainer.cpp.
|
protected |
Constructs a new container for the specified file stream at the specified startOffset.
Definition at line 17 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the attachments have been parsed yet.
Definition at line 193 of file abstractcontainer.h.
|
inline |
Returns an indication whether the chapters have been parsed yet.
Definition at line 185 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tags have been parsed yet.
Definition at line 177 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tracks have been parsed yet.
Definition at line 201 of file abstractcontainer.h.
|
virtual |
Returns the attachment with the specified index.
index must be less than attachmentCount().
Reimplemented in TagParser::MatroskaContainer.
Definition at line 453 of file abstractcontainer.cpp.
|
virtual |
Returns the number of attachments the container holds.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 462 of file abstractcontainer.cpp.
|
virtual |
Returns the chapter with the specified index.
index must be less than chapterCount().
Reimplemented in TagParser::MatroskaContainer.
Definition at line 424 of file abstractcontainer.cpp.
|
virtual |
Returns the number of chapters the container holds.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 433 of file abstractcontainer.cpp.
|
virtual |
Creates and returns a new attachment.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 443 of file abstractcontainer.cpp.
Creates and returns a tag for the specified target.
Reimplemented in TagParser::OggContainer, TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 289 of file abstractcontainer.cpp.
|
inline |
Returns the creation time of the file if known; otherwise the returned date time is null.
Definition at line 284 of file abstractcontainer.h.
|
virtual |
Determines the position of the index.
Reimplemented in TagParser::MatroskaContainer, and TagParser::Mp4Container.
Definition at line 183 of file abstractcontainer.cpp.
|
virtual |
Determines the position of the tags inside the file.
Reimplemented in TagParser::MatroskaContainer, and TagParser::Mp4Container.
Definition at line 357 of file abstractcontainer.cpp.
|
inline |
Returns the document type "read version" if known; otherwise returns 0.
This is the minimum version an interpreter has to support to read the file.
Definition at line 245 of file abstractcontainer.h.
|
inline |
Returns the document type version if known; otherwise returns 0.
Definition at line 235 of file abstractcontainer.h.
|
inline |
Returns a string that describes the document type if available; otherwise returns an empty string.
Definition at line 227 of file abstractcontainer.h.
|
inline |
Returns the duration of the file if known; otherwise returns a time span of zero ticks.
Definition at line 276 of file abstractcontainer.h.
|
protectedvirtual |
Internally called to make the file.
Must be implemented when subclassing.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 272 of file abstractcontainer.cpp.
|
protectedvirtual |
Internally called to parse the attachments.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented in TagParser::MatroskaContainer.
Definition at line 257 of file abstractcontainer.cpp.
|
protectedvirtual |
Internally called to parse the chapters.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented in TagParser::MatroskaContainer.
Definition at line 242 of file abstractcontainer.cpp.
|
protectedvirtual |
Internally called to parse the header.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 197 of file abstractcontainer.cpp.
|
protectedvirtual |
Internally called to parse the tags.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 212 of file abstractcontainer.cpp.
|
protectedvirtual |
Internally called to parse the tracks.
Must be implemented when subclassing to provide this feature.
Throws | Failure or a derived class when a parsing error occurs. |
Throws | std::ios_base::failure when an IO error occurs. |
Reimplemented in TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 227 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the header has been parsed yet.
Definition at line 169 of file abstractcontainer.h.
void TagParser::AbstractContainer::makeFile | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Rewrites the file to apply changed tag information.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a making error occurs. |
Definition at line 161 of file abstractcontainer.cpp.
|
inline |
Returns the modification time of the file if known; otherwise the returned date time is null.
Definition at line 292 of file abstractcontainer.h.
void TagParser::AbstractContainer::parseAttachments | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Parses the attachments of the file if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a parsing error occurs. |
Definition at line 145 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseChapters | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Parses the chapters of the file if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | TagParser::Failure or a derived exception when a parsing error occurs. |
Definition at line 126 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseHeader | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Parses the header if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Failure or a derived class when an parsing error occurs. |
Definition at line 55 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseTags | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Parses the tag information if not parsed yet.
The header will be parsed before if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Failure or a derived class when an parsing error occurs. |
Definition at line 82 of file abstractcontainer.cpp.
void TagParser::AbstractContainer::parseTracks | ( | Diagnostics & | diag, |
AbortableProgressFeedback & | progress | ||
) |
Parses the tracks of the file if not parsed yet.
The header will be parsed before if not parsed yet.
The information will be read from the associated stream. The stream and the start offset have been specified when constructing the object.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Failure or a derived class when an parsing error occurs. |
Definition at line 106 of file abstractcontainer.cpp.
|
inline |
Returns the related BinaryReader.
Definition at line 153 of file abstractcontainer.h.
|
inline |
Returns the "read version" if known; otherwise returns 0.
This is the minimum version a parser has to support to read the file.
Definition at line 219 of file abstractcontainer.h.
|
virtual |
Removes all tags attached to the container.
The tags need to be parsed before they can be removed.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 344 of file abstractcontainer.cpp.
|
virtual |
Removes all tracks from the container.
Modifying tracks might be not supported by the implementation.
The tracks need to be parsed before they can be removed.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 415 of file abstractcontainer.cpp.
|
virtual |
Removes the specified tag from the container.
Does nothing if the tag is not attached to the container.
The tags need to be parsed before a removal is possible.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 328 of file abstractcontainer.cpp.
|
virtual |
Removes the specified track to the container.
Removal of tracks might be not supported by the implementation.
The tracks need to be parsed before a removal is possible.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 396 of file abstractcontainer.cpp.
|
virtual |
Discards all parsing results.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, TagParser::MatroskaContainer, TagParser::Mp4Container, and TagParser::OggContainer.
Definition at line 486 of file abstractcontainer.cpp.
|
virtual |
Returns the number of segments.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 478 of file abstractcontainer.cpp.
|
inline |
Sets the related stream.
Definition at line 135 of file abstractcontainer.h.
|
inline |
Sets the title for the specified segment.
Throws | out_of_range if the segment does not exist. |
Definition at line 268 of file abstractcontainer.h.
|
inline |
Returns the start offset in the related stream.
Definition at line 145 of file abstractcontainer.h.
|
inline |
Returns the related stream.
Definition at line 127 of file abstractcontainer.h.
|
virtual |
Returns whether the title property is supported.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 470 of file abstractcontainer.cpp.
|
virtual |
Returns whether the implementation supports adding or removing of tracks.
Reimplemented in TagParser::Mp4Container.
Definition at line 169 of file abstractcontainer.cpp.
|
virtual |
Returns the tag with the specified index.
index must be less than tagCount().
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 299 of file abstractcontainer.cpp.
|
virtual |
Returns the number of tags attached to the container.
This method returns zero if the tags have not been parsed yet.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >, and TagParser::OggContainer.
Definition at line 310 of file abstractcontainer.cpp.
|
inline |
Returns the time scale of the file if known; otherwise returns 0.
Definition at line 300 of file abstractcontainer.h.
|
inline |
Returns the title(s) of the file.
Definition at line 257 of file abstractcontainer.h.
|
virtual |
Returns the track with the specified index.
index must be less than trackCount().
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 368 of file abstractcontainer.cpp.
|
virtual |
Returns the number of tracks the container holds.
Reimplemented in TagParser::GenericContainer< FileInfoType, TagType, TrackType, ElementType >, TagParser::GenericContainer< MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement >, TagParser::GenericContainer< MediaFileInfo, Mp4Tag, Mp4Track, Mp4Atom >, and TagParser::GenericContainer< MediaFileInfo, OggVorbisComment, OggStream, OggPage >.
Definition at line 377 of file abstractcontainer.cpp.
|
inline |
Returns the version if known; otherwise returns 0.
Definition at line 209 of file abstractcontainer.h.
|
inline |
Returns the related BinaryWriter.
Definition at line 161 of file abstractcontainer.h.
|
protected |
Definition at line 115 of file abstractcontainer.h.
|
protected |
Definition at line 114 of file abstractcontainer.h.
|
protected |
Definition at line 106 of file abstractcontainer.h.
|
protected |
Definition at line 101 of file abstractcontainer.h.
|
protected |
Definition at line 103 of file abstractcontainer.h.
|
protected |
Definition at line 102 of file abstractcontainer.h.
|
protected |
Definition at line 105 of file abstractcontainer.h.
|
protected |
Definition at line 110 of file abstractcontainer.h.
|
protected |
Definition at line 107 of file abstractcontainer.h.
|
protected |
Definition at line 100 of file abstractcontainer.h.
|
protected |
Definition at line 111 of file abstractcontainer.h.
|
protected |
Definition at line 108 of file abstractcontainer.h.
|
protected |
Definition at line 104 of file abstractcontainer.h.
|
protected |
Definition at line 113 of file abstractcontainer.h.
|
protected |
Definition at line 112 of file abstractcontainer.h.
|
protected |
Definition at line 99 of file abstractcontainer.h.