1 // OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPObjClass.cpp,v 1.3.6.3 2008/09/02 23:58:15 quanah Exp 2 /* 3 * Copyright 2003, OpenLDAP Foundation, All Rights Reserved. 4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file 5 */ 6 7 #include "debug.h" 8 #include "LDAPObjClass.h" 9 10 11 LDAPObjClass::LDAPObjClass(){ 12 DEBUG(LDAP_DEBUG_CONSTRUCT, 13 "LDAPObjClass::LDAPObjClass( )" << endl); 14 15 oid = string (); 16 desc = string (); 17 names = StringList (); 18 must = StringList(); 19 may = StringList(); 20 sup = StringList(); 21 } 22 23 LDAPObjClass::LDAPObjClass (const LDAPObjClass &oc){ 24 DEBUG(LDAP_DEBUG_CONSTRUCT, 25 "LDAPObjClass::LDAPObjClass( )" << endl); 26 27 oid = oc.oid; 28 desc = oc.desc; 29 names = oc.names; 30 must = oc.must; 31 may = oc.may; 32 kind = oc.kind; 33 sup = oc.sup; 34 } 35 36 LDAPObjClass::LDAPObjClass (string oc_item, int flags ) { 37 38 DEBUG(LDAP_DEBUG_CONSTRUCT, 39 "LDAPObjClass::LDAPObjClass( )" << endl); 40 41 LDAPObjectClass *o; 42 int ret; 43 const char *errp; 44 o = ldap_str2objectclass ( oc_item.c_str(), &ret, &errp, flags ); 45 46 if (o) { 47 this->setNames (o->oc_names); 48 this->setDesc (o->oc_desc); 49 this->setOid (o->oc_oid); 50 this->setKind (o->oc_kind); 51 this->setMust (o->oc_at_oids_must); 52 this->setMay (o->oc_at_oids_may); 53 this->setSup (o->oc_sup_oids); 54 } 55 // else? -> error 56 } 57 58 LDAPObjClass::~LDAPObjClass() { 59 DEBUG(LDAP_DEBUG_DESTROY,"LDAPObjClass::~LDAPObjClass()" << endl); 60 } 61 62 void LDAPObjClass::setKind (int oc_kind) { 63 kind = oc_kind; 64 } 65 66 void LDAPObjClass::setNames (char **oc_names) { 67 names = StringList (oc_names); 68 } 69 70 void LDAPObjClass::setMust (char **oc_must) { 71 must = StringList (oc_must); 72 } 73 74 void LDAPObjClass::setMay (char **oc_may) { 75 may = StringList (oc_may); 76 } 77 78 void LDAPObjClass::setSup (char **oc_sup) { 79 sup = StringList (oc_sup); 80 } 81 82 void LDAPObjClass::setDesc (char *oc_desc) { 83 desc = string (); 84 if (oc_desc) 85 desc = oc_desc; 86 } 87 88 void LDAPObjClass::setOid (char *oc_oid) { 89 oid = string (); 90 if (oc_oid) 91 oid = oc_oid; 92 } 93 94 string LDAPObjClass::getOid() const { 95 return oid; 96 } 97 98 string LDAPObjClass::getDesc() const { 99 return desc; 100 } 101 102 StringList LDAPObjClass::getNames() const { 103 return names; 104 } 105 106 StringList LDAPObjClass::getMust() const { 107 return must; 108 } 109 110 StringList LDAPObjClass::getMay() const { 111 return may; 112 } 113 114 StringList LDAPObjClass::getSup() const { 115 return sup; 116 } 117 118 string LDAPObjClass::getName() const { 119 120 if (names.empty()) 121 return ""; 122 else 123 return *(names.begin()); 124 } 125 126 int LDAPObjClass::getKind() const { 127 return kind; 128 } 129 130 131