39 #if !defined(TAWARA_ATTACHMENTS_H_)
40 #define TAWARA_ATTACHMENTS_H_
42 #include <boost/operators.hpp>
43 #include <boost/shared_ptr.hpp>
70 typedef boost::shared_ptr<FileData>
Ptr;
72 typedef boost::shared_ptr<FileData const>
ConstPtr;
81 public boost::equality_comparable<AttachedFile>
95 std::string
const& mime_type,
109 std::string
name()
const {
return name_; }
111 void name(std::string
const& name) { name_ =
name; }
138 uint64_t
uid()
const {
return uid_; }
140 void uid(uint64_t uid);
158 virtual std::streamsize body_size()
const;
161 virtual std::streamsize read_body(std::istream& input,
162 std::streamsize
size);
165 virtual std::streamsize write_body(std::ostream& output);
186 public boost::equality_comparable<Attachments>
198 typedef std::vector<AttachedFile>::iterator
iterator;
204 typedef std::vector<AttachedFile>::const_reverse_iterator
216 virtual value_type&
at(size_type pos)
217 {
return files_.at(pos); }
224 virtual value_type
const&
at(size_type pos)
const
225 {
return files_.at(pos); }
234 {
return files_[pos]; }
242 {
return files_[pos]; }
245 virtual iterator
begin() {
return files_.begin(); }
247 virtual const_iterator
begin()
const {
return files_.begin(); }
249 virtual iterator
end() {
return files_.end(); }
251 virtual const_iterator
end()
const {
return files_.end(); }
253 virtual reverse_iterator
rbegin() {
return files_.rbegin(); }
256 {
return files_.rbegin(); }
260 virtual reverse_iterator
rend() {
return files_.rend(); }
271 virtual bool empty()
const {
return files_.empty(); }
273 virtual size_type
count()
const {
return files_.size(); }
275 virtual size_type
max_count()
const {
return files_.max_size(); }
278 virtual void clear() { files_.clear(); }
284 virtual void erase(iterator position) { files_.erase(position); }
290 virtual void erase(iterator first, iterator last)
291 { files_.erase(first, last); }
295 { files_.push_back(value); }
298 virtual void resize(size_type count) { files_.resize(count); }
319 virtual std::streamsize body_size()
const;
322 virtual std::streamsize write_body(std::ostream& output);
325 virtual std::streamsize read_body(std::istream& input,
326 std::streamsize
size);
336 #endif // TAWARA_ATTACHMENTS_H_
virtual size_type count() const
Get the number of attachments.
FileData::ConstPtr data() const
Get the file data.
virtual bool empty() const
Check if there are no attachments.
virtual iterator end()
Get an iterator to the position past the last attachment.
std::vector< AttachedFile >::const_reverse_iterator const_reverse_iterator
The constant reversed random access iterator type.
The Attachments element stores opaque data attached to a segment.
virtual value_type & operator[](size_type pos)
Get a reference to an attachment.
virtual void erase(iterator position)
Erase the attachment at the specified iterator.
virtual const_iterator begin() const
Get an iterator to the first attachment.
virtual value_type const & operator[](size_type pos) const
Get a reference to an attachment.
std::streamsize size(ID id)
Get the number of bytes required by an ID.
boost::shared_ptr< FileData > Ptr
Type of a pointer to a FileData instance.
std::vector< AttachedFile >::reverse_iterator reverse_iterator
The reversed random access iterator type.
virtual const_iterator end() const
Get an iterator to the position past the last attachment.
virtual const_reverse_iterator rend() const
Get a reverse iterator to the position before the first attachment.
The MasterElement interface.
virtual const_reverse_iterator rbegin() const
Get a reverse iterator to the last attachment.
Binary primitive element.
virtual reverse_iterator rend()
Get a reverse iterator to the position before the first attachment.
std::vector< AttachedFile > files_
std::string description() const
Get the attachment's description.
uint64_t uid() const
Get the attached file's UID.
bool operator==(AttachedFile const &lhs, AttachedFile const &rhs)
Equality operator for the AttachedFile object.
virtual void clear()
Remove all attachments.
std::vector< AttachedFile >::value_type value_type
The value type of this container.
FileData(std::vector< char > data)
Constructor.
Unsigned integer primitive element.
std::vector< AttachedFile >::const_iterator const_iterator
The constant random access iterator type.
String primitive element.
virtual void erase(iterator first, iterator last)
Erase a range of attachments.
std::vector< AttachedFile >::const_reference const_reference
The constant reference type.
void name(std::string const &name)
Set the attachment's file name.
std::vector< AttachedFile >::iterator iterator
The random access iterator type.
The data of an attached file.
virtual void swap(Attachments &other)
Swaps the contents of this Attachments element with another.
const ID Attachments(0x1941A469)
std::string name() const
Get the attachment's file name.
virtual reverse_iterator rbegin()
Get a reverse iterator to the last attachment.
An attachment is a binary blob attached to a segment.
virtual void resize(size_type count)
Resizes the attachments storage.
virtual size_type max_count() const
Get the maximum number of attachments.
virtual void push_back(value_type const &value)
Add an attachment.
virtual value_type & at(size_type pos)
Get the attachment at the given position, with bounds checking.
void description(std::string const &desc)
Set the attachment's description.
std::string mime_type() const
Get the MIME type of the file.
const ID AttachedFile(0x61A7)
std::vector< AttachedFile >::reference reference
The reference type.
void mime_type(std::string const &mime_type)
Set the MIME type of the file.
std::vector< AttachedFile >::size_type size_type
The size type of this container.
virtual value_type const & at(size_type pos) const
Get the attachment at the given position, with bounds checking.
boost::shared_ptr< FileData const > ConstPtr
Type of a pointer to a const FileData instance.
virtual iterator begin()
Get an iterator to the first attachment.