Tag Parser
9.1.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Go to the documentation of this file.
6 #include <c++utilities/io/copy.h>
26 StreamDataBlock::StreamDataBlock()
44 std::istream::off_type endOffset, std::ios_base::seekdir endDir)
48 auto currentPos = s.tellg();
55 throw std::ios_base::failure(
"End offset is less than start offset.");
106 m_fileInfo->setPath(path);
107 m_fileInfo->open(
true);
108 m_fileInfo->parseContainerFormat(diag);
111 m_stream = [
this]() -> std::istream & {
return this->m_fileInfo->stream(); };
135 ss <<
"ID: " <<
id();
136 if (!
name().empty()) {
137 ss <<
", name: \"" <<
name() <<
"\"";
140 ss <<
", mime-type: \"" <<
mimeType() <<
"\"";
150 m_description.clear();
173 auto file = make_unique<FileDataBlock>(path, diag);
174 const auto fileName = file->fileInfo()->fileName();
175 if (!fileName.empty()) {
178 const char *
mimeType = file->fileInfo()->mimeType();
183 m_isDataFromFile =
true;
void makeBuffer() const
Buffers the data block.
std::istream::pos_type startOffset() const
Returns the absolute start offset of the data block in the stream.
std::string label() const
Returns a label for the track.
std::istream & stream() const
Returns the associated stream.
void copyTo(std::ostream &stream) const
Copies the data to the specified stream.
FileDataBlock(const std::string &path, Diagnostics &diag)
Constructs a new FileDataBlock with the specified path.
std::istream::pos_type size() const
Returns the size of the data block.
const std::string & name() const
Returns the (file) name of the attachment.
const std::string & mimeType() const
Returns the MIME-type of the attachment.
The Diagnostics class is a container for DiagMessage.
std::uint64_t id() const
Returns the ID of the attachment.
Contains all classes and functions of the TagInfo library.
std::istream::pos_type m_endOffset
std::istream::pos_type m_startOffset
const std::unique_ptr< char[]> & buffer() const
Returns the data buffered via makeBuffer().
StreamDataBlock()
Constructs a new StreamDataBlock.
std::function< std::istream &()> m_stream
virtual ~StreamDataBlock()
Discards buffered data.
~FileDataBlock()
Destroys the FileDataBlock.
void clear()
Resets the object to its initial state.
std::unique_ptr< char[]> m_buffer
std::istream::pos_type endOffset() const
Returns the absolute end offset of the data block in the stream.
void setFile(const std::string &path, Diagnostics &diag)
Sets the data, name and MIME-type for the specified path.