#include "types.hh" #include #include namespace pEp { template<> template<> ::pEp_identity* Wrapper<::pEp_identity*>::_new( const char* address, const char* fpr, const char* user_id, const char* username) { return ::new_identity(address, fpr, user_id, username); } template<> void Wrapper<::pEp_identity*>::_free(::pEp_identity* id) { ::free_identity(id); } template<> ::pEp_identity* Wrapper<::pEp_identity*>::copy_out() const { return identity_dup(value); } ////////////// template<> void Wrapper<::identity_list*>::_free(::identity_list* sl) { ::free_identity_list(sl); } template<> ::identity_list* Wrapper<::identity_list*>::copy_out() const { return identity_list_dup(value); } template<> ::pEp_identity* identity_list::*const ListWrapper<::identity_list*, ::pEp_identity*>::Value = &identity_list::ident; template<> int IdentityList::size() const { return identity_list_length(value); } // faster than .size()==0 because it's not necessary to iterate throgh the whole list template<> bool IdentityList::empty() const { return !(value && value->ident); } template<> void IdentityList::clear() { free_identity_list(value); value = nullptr; } template<> void IdentityList::push_back(pEp_identity*&& id) { auto last = identity_list_add(value, id); if (value == nullptr) value = last; } template<> ListWrapper<::identity_list*, pEp_identity*>::ListWrapper( const std::initializer_list>& il) : Base{} { ::identity_list* last = nullptr; for (const Wrapper& id : il) { last = identity_list_add(last, identity_dup(id.get())); if (last == nullptr) { throw std::runtime_error("Cannot create StringPairList from {}: Out Of Memory."); } if (value == nullptr) value = last; // save the head of linked list. } } //////////////// template class ListWrapper<::identity_list*, ::pEp_identity*>; } // end of namespace pEp