Tawara
0.1.0
|
An attachment is a binary blob attached to a segment. More...
#include <tawara/attachments.h>
Public Member Functions | |
AttachedFile () | |
Constructor. More... | |
AttachedFile (std::string const &name, std::string const &mime_type, FileData::Ptr data, uint64_t uid) | |
Constructor. More... | |
std::string | description () const |
Get the attachment's description. More... | |
void | description (std::string const &desc) |
Set the attachment's description. More... | |
std::string | name () const |
Get the attachment's file name. More... | |
void | name (std::string const &name) |
Set the attachment's file name. More... | |
std::string | mime_type () const |
Get the MIME type of the file. More... | |
void | mime_type (std::string const &mime_type) |
Set the MIME type of the file. More... | |
FileData::ConstPtr | data () const |
Get the file data. More... | |
void | data (FileData::Ptr &data) |
Set the file data. More... | |
uint64_t | uid () const |
Get the attached file's UID. More... | |
void | uid (uint64_t uid) |
Set the attached file's UID. More... | |
![]() | |
MasterElement (uint32_t id, bool crc=false) | |
Create a new MasterElement. More... | |
virtual | ~MasterElement () |
Destructor. More... | |
![]() | |
Element (tawara::ids::ID id) | |
Create a new Element. More... | |
virtual | ~Element () |
Destructor. More... | |
uint32_t | id () const |
Get the element's ID. More... | |
std::streampos | offset () const |
Get the element's offset in the byte stream. More... | |
virtual std::streamsize | size () const |
Get the total size of the element. More... | |
virtual std::streamsize | write (std::ostream &output) |
Element writing. More... | |
virtual std::streamsize | read (std::istream &input) |
Element reading. More... | |
Protected Member Functions | |
virtual std::streamsize | body_size () const |
Get the size of the body of this element. More... | |
virtual std::streamsize | read_body (std::istream &input, std::streamsize size) |
Element body loading. More... | |
virtual std::streamsize | write_body (std::ostream &output) |
Element body writing. More... | |
void | reset () |
Reset the values to their defaults. More... | |
![]() | |
std::streamsize | write_id (std::ostream &output) |
Element ID writing. More... | |
virtual std::streamsize | write_size (std::ostream &output) |
Element size writing. More... | |
Protected Attributes | |
StringElement | desc_ |
StringElement | name_ |
StringElement | mime_ |
FileData::Ptr | data_ |
UIntElement | uid_ |
![]() | |
tawara::ids::ID | id_ |
std::streampos | offset_ |
Friends | |
bool | operator== (AttachedFile const &lhs, AttachedFile const &rhs) |
Equality operator. More... | |
An attachment is a binary blob attached to a segment.
This object contains a single attachment. Instances are stored in the Attachments class.
Definition at line 80 of file attachments.h.
tawara::AttachedFile::AttachedFile | ( | ) |
Constructor.
tawara::AttachedFile::AttachedFile | ( | std::string const & | name, |
std::string const & | mime_type, | ||
FileData::Ptr | data, | ||
uint64_t | uid | ||
) |
Constructor.
[in] | name | The file name of the attachemnt. |
[in] | mime_type | The MIME type of the stored file. |
[in] | data | The data to be attached. |
[in] | uid | A unique UID to represent the attachment. |
|
protectedvirtual |
Get the size of the body of this element.
Implements tawara::Element.
|
inline |
Get the file data.
The attched file data is stored as a binary blob. How it is interpreted is up to the reading program, and is usually guided by the stored MIME type.
Definition at line 129 of file attachments.h.
void tawara::AttachedFile::data | ( | FileData::Ptr & | data | ) |
Set the file data.
|
inline |
Get the attachment's description.
The attachment's description is a human-friendly name for the attached file.
Definition at line 104 of file attachments.h.
|
inline |
Set the attachment's description.
Definition at line 106 of file attachments.h.
|
inline |
Get the MIME type of the file.
The MIME type is used to identify the type of file stored. Without this, programs reading the file cannot easily recognise the type of file and so how to use it.
Definition at line 119 of file attachments.h.
|
inline |
Set the MIME type of the file.
Definition at line 121 of file attachments.h.
|
inline |
Get the attachment's file name.
Definition at line 109 of file attachments.h.
|
inline |
Set the attachment's file name.
Definition at line 111 of file attachments.h.
|
protectedvirtual |
Element body loading.
Implements tawara::Element.
|
protected |
Reset the values to their defaults.
|
inline |
Get the attached file's UID.
The UID for the attached file is used to identify it within the segment. It should be as unique as possible.
Definition at line 138 of file attachments.h.
void tawara::AttachedFile::uid | ( | uint64_t | uid | ) |
Set the attached file's UID.
|
protectedvirtual |
Element body writing.
Implements tawara::Element.
|
friend |
Equality operator.
|
protected |
Definition at line 150 of file attachments.h.
|
protected |
Definition at line 147 of file attachments.h.
|
protected |
Definition at line 149 of file attachments.h.
|
protected |
Definition at line 148 of file attachments.h.
|
protected |
Definition at line 151 of file attachments.h.