Back to index

openldap  2.4.31
LDAPObjClass.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2003-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 #include "debug.h"
00008 #include "LDAPObjClass.h"
00009 
00010 
00011 LDAPObjClass::LDAPObjClass(){
00012     DEBUG(LDAP_DEBUG_CONSTRUCT,
00013             "LDAPObjClass::LDAPObjClass( )" << endl);
00014 
00015     oid = string ();
00016     desc = string ();
00017     names = StringList ();
00018     must = StringList();
00019     may = StringList();
00020     sup = StringList();
00021 }
00022 
00023 LDAPObjClass::LDAPObjClass (const LDAPObjClass &oc){
00024     DEBUG(LDAP_DEBUG_CONSTRUCT,
00025             "LDAPObjClass::LDAPObjClass( )" << endl);
00026 
00027     oid = oc.oid;
00028     desc = oc.desc;
00029     names = oc.names;
00030     must = oc.must;
00031     may = oc.may;
00032     kind = oc.kind;
00033     sup = oc.sup;
00034 }
00035 
00036 LDAPObjClass::LDAPObjClass (string oc_item, int flags ) { 
00037 
00038     DEBUG(LDAP_DEBUG_CONSTRUCT,
00039             "LDAPObjClass::LDAPObjClass( )" << endl);
00040 
00041     LDAPObjectClass *o;
00042     int ret;
00043     const char *errp;
00044     o = ldap_str2objectclass ( oc_item.c_str(), &ret, &errp, flags );
00045 
00046     if (o) {
00047         this->setNames (o->oc_names);
00048        this->setDesc (o->oc_desc);
00049         this->setOid (o->oc_oid);
00050        this->setKind (o->oc_kind);
00051         this->setMust (o->oc_at_oids_must);
00052        this->setMay (o->oc_at_oids_may);
00053         this->setSup (o->oc_sup_oids);
00054     }
00055     // else? -> error
00056 }
00057 
00058 LDAPObjClass::~LDAPObjClass() {
00059     DEBUG(LDAP_DEBUG_DESTROY,"LDAPObjClass::~LDAPObjClass()" << endl);
00060 }
00061 
00062 void LDAPObjClass::setKind (int oc_kind) {
00063     kind = oc_kind;
00064 }
00065     
00066 void LDAPObjClass::setNames (char **oc_names) {
00067     names = StringList (oc_names);
00068 }
00069 
00070 void LDAPObjClass::setMust (char **oc_must) {
00071     must = StringList (oc_must);
00072 }
00073 
00074 void LDAPObjClass::setMay (char **oc_may) {
00075     may = StringList (oc_may);
00076 }
00077 
00078 void LDAPObjClass::setSup (char **oc_sup) {
00079     sup = StringList (oc_sup);
00080 }
00081 
00082 void LDAPObjClass::setDesc (char *oc_desc) {
00083     desc = string ();
00084     if (oc_desc)
00085        desc = oc_desc;
00086 }
00087 
00088 void LDAPObjClass::setOid (char *oc_oid) {
00089     oid = string ();
00090     if (oc_oid)
00091        oid = oc_oid;
00092 }
00093 
00094 string LDAPObjClass::getOid() const {
00095     return oid;
00096 }
00097 
00098 string LDAPObjClass::getDesc() const {
00099     return desc;
00100 }
00101 
00102 StringList LDAPObjClass::getNames() const {
00103     return names;
00104 }
00105 
00106 StringList LDAPObjClass::getMust() const {
00107     return must;
00108 }
00109 
00110 StringList LDAPObjClass::getMay() const {
00111     return may;
00112 }
00113 
00114 StringList LDAPObjClass::getSup() const {
00115     return sup;
00116 }
00117 
00118 string LDAPObjClass::getName() const {
00119 
00120     if (names.empty())
00121        return "";
00122     else
00123        return *(names.begin());
00124 }
00125 
00126 int LDAPObjClass::getKind() const {
00127      return kind;
00128 }
00129 
00130