Back to index

openldap  2.4.31
LDAPModification.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #include "LDAPModification.h"
00009 #include "debug.h"
00010 
00011 using namespace std;
00012 
00013 LDAPModification::LDAPModification(const LDAPAttribute& attr, mod_op op){
00014     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPModification::LDAPModification()" << endl);
00015     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
00016             "   attr:" << attr << endl);
00017     m_attr = attr;
00018     m_mod_op = op;
00019 }
00020 
00021 LDAPMod* LDAPModification::toLDAPMod() const  {
00022     DEBUG(LDAP_DEBUG_TRACE,"LDAPModification::toLDAPMod()" << endl);
00023     LDAPMod* ret=m_attr.toLDAPMod();
00024 
00025     //The mod_op value of the LDAPMod-struct needs to be ORed with the right
00026     // LDAP_MOD_* constant to preserve the BIN-flag (see CAPI-draft for 
00027     // explanation of the LDAPMod struct)
00028     switch (m_mod_op){
00029        case OP_ADD :
00030            ret->mod_op |= LDAP_MOD_ADD;
00031        break;
00032        case OP_DELETE :
00033            ret->mod_op |= LDAP_MOD_DELETE;
00034        break;
00035        case OP_REPLACE :
00036            ret->mod_op |= LDAP_MOD_REPLACE;
00037        break;
00038     }
00039     return ret;
00040 }
00041 
00042 const LDAPAttribute* LDAPModification::getAttribute() const {
00043        return &m_attr;
00044 }
00045 
00046 LDAPModification::mod_op LDAPModification::getOperation() const {
00047        return m_mod_op;
00048 }