A C++ wrapper for the basic C datatypes defined by the pEpEngine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

62 lines
1.6 KiB

// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef LIBPEPDATATYPES_BLOBLIST_HH
#define LIBPEPDATATYPES_BLOBLIST_HH
#include "wrapper.hh"
#include <pEp/bloblist.h>
namespace pEp
{
template<>
class ListWrapper<::bloblist_t*, void> : public Wrapper<::bloblist_t*>
{
public:
typedef ::bloblist_t Blob;
typedef Wrapper<Blob*> Base;
typedef ListWrapper<Blob*, void> LW;
// does not own the *value
class iterator
{
public:
iterator() = default;
iterator operator++() { return (value ? value = value->next : value); }
Blob& operator*() { return *value; }
Blob* operator->() { return value; }
const Blob& operator*() const { return *value; }
const Blob* operator->() const { return value; }
bool operator==(const iterator& other) const { return value == other.value; }
bool operator!=(const iterator& other) const { return value != other.value; }
private:
iterator(::bloblist_t* _t) : value{_t} {}
::bloblist_t* value = nullptr;
friend class ListWrapper<::bloblist_t*, void>;
};
using Base::value;
ListWrapper() : Base() {}
iterator begin() { return iterator{value}; }
iterator end() const { return iterator{}; }
int size() const;
bool empty() const;
void clear();
void push_back(Blob&&);
void emplace_back(char* data, size_t size, const char* mime_type, const char* filename);
};
using BlobList = ListWrapper<::bloblist_t*, void>;
} // end of namespace pEp
#endif // LIBPEPDATATYPES_BLOBLIST_HH