xref: /netbsd-src/external/bsd/openldap/dist/contrib/ldapc++/src/LDAPModification.cpp (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
1 // $OpenLDAP$
2 /*
3  * Copyright 2000-2021 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 
7 
8 #include "LDAPModification.h"
9 #include "debug.h"
10 
11 using namespace std;
12 
LDAPModification(const LDAPAttribute & attr,mod_op op)13 LDAPModification::LDAPModification(const LDAPAttribute& attr, mod_op op){
14     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPModification::LDAPModification()" << endl);
15     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
16             "   attr:" << attr << endl);
17     m_attr = attr;
18     m_mod_op = op;
19 }
20 
toLDAPMod() const21 LDAPMod* LDAPModification::toLDAPMod() const  {
22     DEBUG(LDAP_DEBUG_TRACE,"LDAPModification::toLDAPMod()" << endl);
23     LDAPMod* ret=m_attr.toLDAPMod();
24 
25     //The mod_op value of the LDAPMod-struct needs to be ORed with the right
26     // LDAP_MOD_* constant to preserve the BIN-flag (see CAPI-draft for
27     // explanation of the LDAPMod struct)
28     switch (m_mod_op){
29 	case OP_ADD :
30 	    ret->mod_op |= LDAP_MOD_ADD;
31 	break;
32 	case OP_DELETE :
33 	    ret->mod_op |= LDAP_MOD_DELETE;
34 	break;
35 	case OP_REPLACE :
36 	    ret->mod_op |= LDAP_MOD_REPLACE;
37 	break;
38     }
39     return ret;
40 }
41 
getAttribute() const42 const LDAPAttribute* LDAPModification::getAttribute() const {
43 	return &m_attr;
44 }
45 
getOperation() const46 LDAPModification::mod_op LDAPModification::getOperation() const {
47 	return m_mod_op;
48 }
49