7#include <c++utilities/io/copy.h>
48 std::uint64_t endOffset, std::ios_base::seekdir endDir)
52 auto currentPos = s.tellg();
53 s.seekg(
static_cast<std::istream::off_type
>(
startOffset), startDir);
55 s.seekg(
static_cast<std::istream::off_type
>(
endOffset), endDir);
56 m_endOffset =
static_cast<std::uint64_t
>(s.tellg());
59 throw std::ios_base::failure(
"End offset is less than start offset.");
89 CopyHelper<0x2000> copyHelper;
110 m_fileInfo->setPath(path);
111 m_fileInfo->open(
true);
112 m_fileInfo->parseContainerFormat(diag, progress);
115 m_stream = [
this]() -> std::istream & {
return this->m_fileInfo->stream(); };
138 , m_isDataFromFile(false)
156 ss <<
"ID: " <<
id();
157 if (!
name().empty()) {
158 ss <<
", name: \"" <<
name() <<
"\"";
161 ss <<
", mime-type: \"" <<
mimeType() <<
"\"";
171 m_description.clear();
194 auto file = make_unique<FileDataBlock>(path, diag, progress);
195 const auto fileName = file->fileInfo()->fileName();
196 if (!fileName.empty()) {
199 const auto mimeType = file->fileInfo()->mimeType();
203 m_data = std::move(file);
204 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.
virtual ~AbstractAttachment()
Destroys the attachment.
std::string label() const
Returns a label for the track.
AbstractAttachment()
Constructs a new attachment.
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.
The AbstractAttachmentPrivate struct contains private fields of the AbstractAttachment class.