Tawara  0.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
tawara::AttachedFile Class Reference

An attachment is a binary blob attached to a segment. More...

#include <tawara/attachments.h>

Inheritance diagram for tawara::AttachedFile:
Inheritance graph
[legend]
Collaboration diagram for tawara::AttachedFile:
Collaboration graph
[legend]

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...
 
- Public Member Functions inherited from tawara::MasterElement
 MasterElement (uint32_t id, bool crc=false)
 Create a new MasterElement. More...
 
virtual ~MasterElement ()
 Destructor. More...
 
- Public Member Functions inherited from tawara::Element
 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...
 
- Protected Member Functions inherited from tawara::Element
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_
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Friends

bool operator== (AttachedFile const &lhs, AttachedFile const &rhs)
 Equality operator. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

tawara::AttachedFile::AttachedFile ( )

Constructor.

tawara::AttachedFile::AttachedFile ( std::string const &  name,
std::string const &  mime_type,
FileData::Ptr  data,
uint64_t  uid 
)

Constructor.

Parameters
[in]nameThe file name of the attachemnt.
[in]mime_typeThe MIME type of the stored file.
[in]dataThe data to be attached.
[in]uidA unique UID to represent the attachment.

Member Function Documentation

virtual std::streamsize tawara::AttachedFile::body_size ( ) const
protectedvirtual

Get the size of the body of this element.

Implements tawara::Element.

FileData::ConstPtr tawara::AttachedFile::data ( ) const
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.

std::string tawara::AttachedFile::description ( ) const
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.

void tawara::AttachedFile::description ( std::string const &  desc)
inline

Set the attachment's description.

Definition at line 106 of file attachments.h.

std::string tawara::AttachedFile::mime_type ( ) const
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.

void tawara::AttachedFile::mime_type ( std::string const &  mime_type)
inline

Set the MIME type of the file.

Definition at line 121 of file attachments.h.

std::string tawara::AttachedFile::name ( ) const
inline

Get the attachment's file name.

Definition at line 109 of file attachments.h.

void tawara::AttachedFile::name ( std::string const &  name)
inline

Set the attachment's file name.

Definition at line 111 of file attachments.h.

virtual std::streamsize tawara::AttachedFile::read_body ( std::istream &  input,
std::streamsize  size 
)
protectedvirtual

Element body loading.

Implements tawara::Element.

void tawara::AttachedFile::reset ( )
protected

Reset the values to their defaults.

uint64_t tawara::AttachedFile::uid ( ) const
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.

virtual std::streamsize tawara::AttachedFile::write_body ( std::ostream &  output)
protectedvirtual

Element body writing.

Implements tawara::Element.

Friends And Related Function Documentation

bool operator== ( AttachedFile const &  lhs,
AttachedFile const &  rhs 
)
friend

Equality operator.

Member Data Documentation

FileData::Ptr tawara::AttachedFile::data_
protected

Definition at line 150 of file attachments.h.

StringElement tawara::AttachedFile::desc_
protected

Definition at line 147 of file attachments.h.

StringElement tawara::AttachedFile::mime_
protected

Definition at line 149 of file attachments.h.

StringElement tawara::AttachedFile::name_
protected

Definition at line 148 of file attachments.h.

UIntElement tawara::AttachedFile::uid_
protected

Definition at line 151 of file attachments.h.


The documentation for this class was generated from the following file: