Browse Source

attach and detach C structs

AllGroupDevicesShowHandshake
Volker Birk 6 years ago
parent
commit
b0b6859056
2 changed files with 27 additions and 0 deletions
  1. +24
    -0
      src/Identity.cc
  2. +3
    -0
      src/Identity.hh

+ 24
- 0
src/Identity.cc View File

@ -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
- 0
src/Identity.hh View File

@ -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