Browse Source

attach and detach C structs

master
Volker Birk 9 years ago
parent
commit
b0b6859056
  1. 24
      src/Identity.cc
  2. 3
      src/Identity.hh

24
src/Identity.cc

@ -19,11 +19,35 @@ namespace pEp {
throw bad_alloc();
}
Identity::Identity(pEp_identity *ident)
: _ident(ident)
{
}
Identity::~Identity()
{
free_identity(_ident);
}
void Identity::attach(pEp_identity *ident)
{
free_identity(_ident);
_ident = ident;
}
pEp_identity *Identity::detach()
{
pEp_identity *new_one = new_identity(NULL, NULL, NULL, NULL);
if (!new_one)
throw bad_alloc();
pEp_identity *ident = _ident;
_ident = new_one;
return ident;
}
Identity::operator pEp_identity *()
{
if (!_ident)

3
src/Identity.hh

@ -16,8 +16,11 @@ namespace pEp {
public:
Identity();
Identity(const Identity& second);
Identity(pEp_identity *ident);
~Identity();
operator pEp_identity *();
void attach(pEp_identity *ident);
pEp_identity *detach();
void address(string value) { str_attr(_ident->address, value); }
string address() { return str_attr(_ident->address); }

Loading…
Cancel
Save