1#ifndef TAG_PARSER_GENERICCONTAINER_H
2#define TAG_PARSER_GENERICCONTAINER_H
39 const std::vector<std::unique_ptr<TagType>> &
tags()
const;
40 std::vector<std::unique_ptr<TagType>> &
tags();
41 const std::vector<std::unique_ptr<TrackType>> &
tracks()
const;
42 std::vector<std::unique_ptr<TrackType>> &
tracks();
60 std::vector<std::unique_ptr<TagType>>
m_tags;
61 std::vector<std::unique_ptr<TrackType>>
m_tracks;
64 FileInfoType *m_fileInfo;
70template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
83template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
98template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
104 m_firstElement->validateSubsequentElementStructure(diag, paddingSize, &progress);
113template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
131template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
144template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
157template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
163template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
166 return m_tags[index].get();
169template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
175template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
181template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
185 if (
track->id() ==
id) {
192template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
207template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
222template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
237template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
252template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
258template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
265 if (
tag->target() == target) {
270 return m_tags.front().get();
275 const auto &
tag =
m_tags.emplace_back(std::make_unique<TagType>());
276 tag->setTarget(target);
280template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
283 if (
const auto size =
m_tags.size()) {
285 [
tag](
const std::unique_ptr<TagType> &existingTag) ->
bool { return static_cast<Tag *>(existingTag.get()) == tag; }),
287 return size !=
m_tags.size();
292template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
314template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
321 auto id =
track->id();
323 for (
const auto &existingTrack :
m_tracks) {
324 if (existingTrack->id() ==
id) {
326 goto ensureIdIsUnique;
335template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
341 auto removed =
false;
358template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
367template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
42 std::vector<std::unique_ptr<TrackType>> &
tracks(); {
…}
41 const std::vector<std::unique_ptr<TrackType>> &
tracks()
const; {
…}
40 std::vector<std::unique_ptr<TagType>> &
tags(); {
…}
39 const std::vector<std::unique_ptr<TagType>> &
tags()
const; {
…}
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
std::iostream & stream()
Returns the related stream.
std::uint64_t startOffset() const
Returns the start offset in the related stream.
bool areTracksParsed() const
Returns an indication whether the tracks have been parsed yet.
virtual bool supportsTrackModifications() const
Returns whether the implementation supports adding or removing of tracks.
virtual void reset()
Discards all parsing results.
void parseHeader(Diagnostics &diag, AbortableProgressFeedback &progress)
Parses the header if not parsed yet.
AbstractContainer(std::iostream &stream, std::uint64_t startOffset)
Constructs a new container for the specified file stream at the specified startOffset.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
The Diagnostics class is a container for DiagMessage.
const std::vector< std::unique_ptr< TrackType > > & tracks() const
Returns the tracks of the file.
bool removeTrack(AbstractTrack *track) override
Removes the specified track to the container.
TagType * tag(std::size_t index) override
Returns the tag with the specified index.
void validateElementStructure(Diagnostics &diag, AbortableProgressFeedback &progress, std::uint64_t *paddingSize=nullptr)
Parses all elements the file consists of.
bool removeTag(Tag *tag) override
Removes the specified tag from the container.
TrackType * track(std::size_t index) override
Returns the track with the specified index.
void removeAllTags() override
Removes all tags attached to the container.
std::vector< std::unique_ptr< TrackType > > m_tracks
TagType * createTag(const TagTarget &target=TagTarget()) override
Creates and returns a tag for the specified target.
const std::vector< std::unique_ptr< TagType > > & tags() const
Returns the tags of the file.
GenericContainer(FileInfoType &fileInfo, std::uint64_t startOffset)
Constructs a new container for the specified fileInfo at the specified startOffset.
TrackType * trackById(std::uint64_t id)
TrackType ContainerTrackType
bool addTrack(TrackType *track)
Adds the specified track to the container.
std::unique_ptr< ElementType > m_firstElement
ElementType ContainerElementType
MediaFileInfo & fileInfo() const
~GenericContainer() override
Destroys the container.
std::vector< std::unique_ptr< ElementType > > m_additionalElements
void removeAllTracks() override
Removes all tracks from the container.
std::vector< std::unique_ptr< TrackType > > & tracks()
Returns the tracks of the file.
ElementType * firstElement() const
Returns the first element of the file if available; otherwiese returns nullptr.
std::vector< std::unique_ptr< TagType > > m_tags
std::size_t trackCount() const override
Returns the number of tracks the container holds.
std::vector< std::unique_ptr< TagType > > & tags()
Returns the tags of the file.
const std::vector< std::unique_ptr< ElementType > > & additionalElements() const
Returns all available additional elements.
void reset() override
Discards all parsing results.
std::size_t tagCount() const override
Returns the number of tags attached to the container.
FileInfoType ContainerFileInfoType
std::vector< std::unique_ptr< ElementType > > & additionalElements()
Returns all available additional elements.
The TagTarget class specifies the target of a tag.
bool isEmpty() const
Returns an indication whether the target is empty.
The Tag class is used to store, read and write tag information.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.
TagType
Specifies the tag type.
TrackType
The TrackType enum specifies the underlying file type of a track and the concrete class of the track ...