]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPModification.cpp
Added ldif_countlines()
[openldap] / contrib / ldapc++ / src / LDAPModification.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #include "LDAPModification.h"
8 #include "debug.h"
9
10 using namespace std;
11
12 LDAPModification::LDAPModification(const LDAPAttribute& attr, mod_op op){
13     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPModification::LDAPModification()" << endl);
14     DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
15             "   attr:" << attr << endl);
16     m_attr = attr;
17     m_mod_op = op;
18 }
19
20 LDAPMod* LDAPModification::toLDAPMod() const  {
21     DEBUG(LDAP_DEBUG_TRACE,"LDAPModification::toLDAPMod()" << endl);
22     LDAPMod* ret=m_attr.toLDAPMod();
23
24     //The mod_op value of the LDAPMod-struct needs to be ORed with the right
25     // LDAP_MOD_* constant to preserve the BIN-flag (see CAPI-draft for 
26     // explanation of the LDAPMod struct)
27     switch (m_mod_op){
28         case OP_ADD :
29             ret->mod_op |= LDAP_MOD_ADD;
30         break;
31         case OP_DELETE :
32             ret->mod_op |= LDAP_MOD_DELETE;
33         break;
34         case OP_REPLACE :
35             ret->mod_op |= LDAP_MOD_REPLACE;
36         break;
37     }
38     return ret;
39 }