Tag Parser 12.0.0
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. | |
std::iostream & | stream () |
Returns the related stream. | |
void | setStream (std::iostream &stream) |
Sets the related stream. | |
std::uint64_t | startOffset () const |
Returns the start offset in the related stream. | |
CppUtilities::BinaryReader & | reader () |
Returns the related BinaryReader. | |
CppUtilities::BinaryWriter & | writer () |
Returns the related BinaryWriter. | |
void | parseHeader (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the header if not parsed yet. | |
void | parseTags (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the tag information if not parsed yet. | |
void | parseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the tracks of the file if not parsed yet. | |
void | parseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the chapters of the file if not parsed yet. | |
void | parseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) |
Parses the attachments of the file if not parsed yet. | |
void | makeFile (Diagnostics &diag, AbortableProgressFeedback &progress) |
Rewrites the file to apply changed tag information. | |
bool | isHeaderParsed () const |
Returns an indication whether the header has been parsed yet. | |
bool | areTagsParsed () const |
Returns an indication whether the tags have been parsed yet. | |
bool | areTracksParsed () const |
Returns an indication whether the tracks have been parsed yet. | |
bool | areChaptersParsed () const |
Returns an indication whether the chapters have been parsed yet. | |
bool | areAttachmentsParsed () const |
Returns an indication whether the attachments have been parsed yet. | |
virtual Tag * | createTag (const TagTarget &target=TagTarget()) |
Creates and returns a tag for the specified target. | |
virtual Tag * | tag (std::size_t index) |
Returns the tag with the specified index. | |
virtual std::size_t | tagCount () const |
Returns the number of tags attached to the container. | |
virtual bool | removeTag (Tag *tag) |
Removes the specified tag from the container. | |
virtual void | removeAllTags () |
Removes all tags attached to the container. | |
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 std::size_t | trackCount () const |
Returns the number of tracks the container holds. | |
virtual bool | removeTrack (AbstractTrack *track) |
Removes the specified track to the container. | |
virtual void | removeAllTracks () |
Removes all tracks from the container. | |
virtual bool | supportsTrackModifications () const |
Returns whether the implementation supports adding or removing of tracks. | |
virtual ElementPosition | determineIndexPosition (Diagnostics &diag) const |
Determines the position of the index. | |
virtual AbstractChapter * | chapter (std::size_t index) |
Returns the chapter with the specified index. | |
virtual std::size_t | chapterCount () const |
Returns the number of chapters the container holds. | |
virtual AbstractAttachment * | createAttachment () |
Creates and returns a new attachment. | |
virtual AbstractAttachment * | attachment (std::size_t index) |
Returns the attachment with the specified index. | |
virtual std::size_t | attachmentCount () const |
Returns the number of attachments the container holds. | |
std::uint64_t | version () const |
Returns the version if known; otherwise returns 0. | |
std::uint64_t | readVersion () const |
Returns the "read version" if known; otherwise returns 0. | |
const std::string & | documentType () const |
Returns a string that describes the document type if available; otherwise returns an empty string. | |
std::uint64_t | doctypeVersion () const |
Returns the document type version if known; otherwise returns 0. | |
std::uint64_t | doctypeReadVersion () const |
Returns the document type "read version" if known; otherwise returns 0. | |
const std::vector< std::string > & | titles () const |
Returns the title(s) of the file. | |
void | setTitle (std::string_view title, std::size_t segmentIndex=0) |
Sets the title for the specified segment. | |
virtual bool | supportsTitle () const |
Returns whether the title property is supported. | |
virtual std::size_t | segmentCount () const |
Returns the number of segments. | |
CppUtilities::TimeSpan | duration () const |
Returns the duration of the file if known; otherwise returns a time span of zero ticks. | |
CppUtilities::DateTime | creationTime () const |
Returns the creation time of the file if known; otherwise the returned date time is null. | |
CppUtilities::DateTime | modificationTime () const |
Returns the modification time of the file if known; otherwise the returned date time is null. | |
std::uint32_t | timeScale () const |
Returns the time scale of the file if known; otherwise returns 0. | |
virtual void | reset () |
Discards all parsing results. | |
Protected Member Functions | |
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. | |
virtual void | internalParseTags (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the tags. | |
virtual void | internalParseTracks (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the tracks. | |
virtual void | internalParseChapters (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the chapters. | |
virtual void | internalParseAttachments (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to parse the attachments. | |
virtual void | internalMakeFile (Diagnostics &diag, AbortableProgressFeedback &progress) |
Internally called to make the file. | |
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 31 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 45 of file abstractcontainer.cpp.
|
protected |
Constructs a new container for the specified file stream at the specified startOffset.
Definition at line 20 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the attachments have been parsed yet.
Definition at line 196 of file abstractcontainer.h.
|
inline |
Returns an indication whether the chapters have been parsed yet.
Definition at line 188 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tags have been parsed yet.
Definition at line 180 of file abstractcontainer.h.
|
inline |
Returns an indication whether the tracks have been parsed yet.
Definition at line 204 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 456 of file abstractcontainer.cpp.
|
virtual |
Returns the number of attachments the container holds.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 465 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 427 of file abstractcontainer.cpp.
|
virtual |
Returns the number of chapters the container holds.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 436 of file abstractcontainer.cpp.
|
virtual |
Creates and returns a new attachment.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 446 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 292 of file abstractcontainer.cpp.
|
inline |
Returns the creation time of the file if known; otherwise the returned date time is null.
Definition at line 287 of file abstractcontainer.h.
|
virtual |
Determines the position of the index.
Reimplemented in TagParser::MatroskaContainer, and TagParser::Mp4Container.
Definition at line 186 of file abstractcontainer.cpp.
|
virtual |
Determines the position of the tags inside the file.
Reimplemented in TagParser::MatroskaContainer, and TagParser::Mp4Container.
Definition at line 360 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 248 of file abstractcontainer.h.
|
inline |
Returns the document type version if known; otherwise returns 0.
Definition at line 238 of file abstractcontainer.h.
|
inline |
Returns a string that describes the document type if available; otherwise returns an empty string.
Definition at line 230 of file abstractcontainer.h.
|
inline |
Returns the duration of the file if known; otherwise returns a time span of zero ticks.
Definition at line 279 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 275 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 260 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 245 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 200 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 215 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 230 of file abstractcontainer.cpp.
|
inline |
Returns an indication whether the header has been parsed yet.
Definition at line 172 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 164 of file abstractcontainer.cpp.
|
inline |
Returns the modification time of the file if known; otherwise the returned date time is null.
Definition at line 295 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 148 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 129 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 58 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 85 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 109 of file abstractcontainer.cpp.
|
inline |
Returns the related BinaryReader.
Definition at line 156 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 222 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 347 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 418 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 331 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 399 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 489 of file abstractcontainer.cpp.
|
virtual |
Returns the number of segments.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 481 of file abstractcontainer.cpp.
|
inline |
Sets the related stream.
Definition at line 138 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 271 of file abstractcontainer.h.
|
inline |
Returns the start offset in the related stream.
Definition at line 148 of file abstractcontainer.h.
|
inline |
Returns the related stream.
Definition at line 130 of file abstractcontainer.h.
|
virtual |
Returns whether the title property is supported.
Reimplemented in TagParser::MatroskaContainer.
Definition at line 473 of file abstractcontainer.cpp.
|
virtual |
Returns whether the implementation supports adding or removing of tracks.
Reimplemented in TagParser::Mp4Container.
Definition at line 172 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 302 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 313 of file abstractcontainer.cpp.
|
inline |
Returns the time scale of the file if known; otherwise returns 0.
Definition at line 303 of file abstractcontainer.h.
|
inline |
Returns the title(s) of the file.
Definition at line 260 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 371 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 380 of file abstractcontainer.cpp.
|
inline |
Returns the version if known; otherwise returns 0.
Definition at line 212 of file abstractcontainer.h.
|
inline |
Returns the related BinaryWriter.
Definition at line 164 of file abstractcontainer.h.
|
protected |
Definition at line 117 of file abstractcontainer.h.
|
protected |
Definition at line 116 of file abstractcontainer.h.
|
protected |
Definition at line 108 of file abstractcontainer.h.
|
protected |
Definition at line 103 of file abstractcontainer.h.
|
protected |
Definition at line 105 of file abstractcontainer.h.
|
protected |
Definition at line 104 of file abstractcontainer.h.
|
protected |
Definition at line 107 of file abstractcontainer.h.
|
protected |
Definition at line 112 of file abstractcontainer.h.
|
protected |
Definition at line 109 of file abstractcontainer.h.
|
protected |
Definition at line 102 of file abstractcontainer.h.
|
protected |
Definition at line 113 of file abstractcontainer.h.
|
protected |
Definition at line 110 of file abstractcontainer.h.
|
protected |
Definition at line 106 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 101 of file abstractcontainer.h.