Browse Source

attach and detach C structs

PYADPT-55
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(); throw bad_alloc();
} }
Identity::Identity(pEp_identity *ident)
: _ident(ident)
{
}
Identity::~Identity() Identity::~Identity()
{ {
free_identity(_ident); 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 *() Identity::operator pEp_identity *()
{ {
if (!_ident) if (!_ident)

3
src/Identity.hh

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

Loading…
Cancel
Save