7#include <c++utilities/io/copy.h>
45 std::uint64_t endOffset, std::ios_base::seekdir endDir)
49 auto currentPos = s.tellg();
50 s.seekg(
static_cast<std::istream::off_type
>(
startOffset), startDir);
52 s.seekg(
static_cast<std::istream::off_type
>(
endOffset), endDir);
53 m_endOffset =
static_cast<std::uint64_t
>(s.tellg());
56 throw std::ios_base::failure(
"End offset is less than start offset.");
86 CopyHelper<0x2000> copyHelper;
107 m_fileInfo->setPath(path);
108 m_fileInfo->open(
true);
109 m_fileInfo->parseContainerFormat(diag, progress);
112 m_stream = [
this]() -> std::istream & {
return this->m_fileInfo->stream(); };
136 ss <<
"ID: " <<
id();
137 if (!
name().empty()) {
138 ss <<
", name: \"" <<
name() <<
"\"";
141 ss <<
", mime-type: \"" <<
mimeType() <<
"\"";
151 m_description.clear();
174 auto file = make_unique<FileDataBlock>(path, diag, progress);
175 const auto fileName = file->fileInfo()->fileName();
176 if (!fileName.empty()) {
179 const auto mimeType = file->fileInfo()->mimeType();
184 m_isDataFromFile =
true;
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
void clear()
Resets the object to its initial state.
const std::string & mimeType() const
Returns the MIME-type of the attachment.
const std::string & name() const
Returns the (file) name of the attachment.
std::uint64_t id() const
Returns the ID of the attachment.
void setFile(std::string_view path, Diagnostics &diag, AbortableProgressFeedback &progress)
Sets the data, name and MIME-type for the specified path.
std::string label() const
Returns a label for the track.
The Diagnostics class is a container for DiagMessage.
FileDataBlock(std::string_view path, Diagnostics &diag, AbortableProgressFeedback &progress)
Constructs a new FileDataBlock with the specified path.
~FileDataBlock()
Destroys the FileDataBlock.
std::uint64_t m_startOffset
std::uint64_t m_endOffset
std::unique_ptr< char[]> m_buffer
void makeBuffer() const
Buffers the data block.
const std::unique_ptr< char[]> & buffer() const
Returns the data buffered via makeBuffer().
std::uint64_t startOffset() const
Returns the absolute start offset of the data block in the stream.
StreamDataBlock()
Constructs a new StreamDataBlock.
std::uint64_t size() const
Returns the size of the data block.
std::istream & stream() const
Returns the associated stream.
void copyTo(std::ostream &stream) const
Copies the data to the specified stream.
virtual ~StreamDataBlock()
Discards buffered data.
std::uint64_t endOffset() const
Returns the absolute end offset of the data block in the stream.
std::function< std::istream &()> m_stream
Contains all classes and functions of the TagInfo library.