Browse Source

implement missing member functions for StringPair and StringPairList.

master
roker 4 months ago
parent
commit
8f86913011
2 changed files with 51 additions and 1 deletions
  1. +49
    -0
      src/types.cc
  2. +2
    -1
      src/wrapper.hh

+ 49
- 0
src/types.cc View File

@ -65,10 +65,59 @@ namespace pEp
{
free_stringpair(sp);
}
template<>
void Wrapper<::stringpair_list_t*>::_free(::stringpair_list_t* spl)
{
free_stringpair_list(spl);
}
template<>
stringpair_t* stringpair_list_t::* const ListWrapper<stringpair_list_t*, stringpair_t*>::Value = &stringpair_list_t::value;
template<>
int StringPairList::size() const
{
return stringpair_list_length(value);
}
// faster than .size()==0 because it's not necessary to iterate throgh the whole list
template<>
bool StringPairList::empty() const
{
return value && value->value;
}
template<>
void StringPairList::erase( const StringPairList::iterator& it)
{
if(it.value && it.value->value && it.value->value->key)
{
value = stringpair_list_delete_by_key(value, it.value->value->key);
}
}
template<>
void StringPairList::clear()
{
free_stringpair_list(value);
value = nullptr;
}
template<>
void StringPairList::push_back(::stringpair_t*&& sp)
{
stringpair_list_add(value, sp);
sp = nullptr;
}
template<>
void StringPairList::push_back(StringPair&& sp)
{
stringpair_list_add(value, sp.move_out());
}
////////////////
template class Wrapper<::pEp_identity>;


+ 2
- 1
src/wrapper.hh View File

@ -78,7 +78,7 @@ public:
}
const T* get() const { return value; }
T* move_out() && { T* r = value; value=nullptr; return r;}
T* move_out() { T* r = value; value=nullptr; return r;}
friend
bool operator==(const Wrapper<T*>& a, const Wrapper<T*>& b);
@ -151,6 +151,7 @@ public:
void erase(const iterator& it);
void clear();
void push_back(Element&&);
void push_back(Wrapper<Element>&&);
};


Loading…
Cancel
Save