Back to index

openldap  2.4.31
LDAPSchema.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 "LDAPSchema.h"
00008 
00009 #include <ctype.h>
00010 #include <ldap.h>
00011 
00012 #include "debug.h"
00013 #include "StringList.h"
00014 
00015 
00016 using namespace std;
00017 
00018 LDAPSchema::LDAPSchema(){
00019     DEBUG(LDAP_DEBUG_CONSTRUCT,
00020             "LDAPSchema::LDAPSchema( )" << endl);
00021 }
00022 
00023 LDAPSchema::~LDAPSchema() {
00024     DEBUG(LDAP_DEBUG_DESTROY,"LDAPSchema::~LDAPSchema()" << endl);
00025 }
00026 
00027 void LDAPSchema::setObjectClasses (const StringList &ocs) {
00028     DEBUG(LDAP_DEBUG_TRACE,"LDAPSchema::setObjectClasses()" << endl);
00029     
00030     // parse the stringlist and save it to global map...
00031     StringList::const_iterator i,j;
00032     for (i = ocs.begin(); i != ocs.end(); i++) {
00033        LDAPObjClass oc ( (*i) );
00034        StringList names = oc.getNames();
00035        // there could be more names for one object...
00036        for (j = names.begin(); j != names.end(); j++) {
00037             string lc_name = *j;
00038             string::iterator k;
00039             for ( k = lc_name.begin(); k != lc_name.end(); k++ ) {
00040                 (*k) = tolower(*k); 
00041             }
00042            object_classes [lc_name] = LDAPObjClass (oc);
00043        }
00044     }
00045 }
00046 
00047 void LDAPSchema::setAttributeTypes (const StringList &ats) {
00048     DEBUG(LDAP_DEBUG_TRACE,"LDAPSchema::setAttributeTypes()" << endl);
00049     
00050     // parse the stringlist and save it to global map...
00051     StringList::const_iterator i,j;
00052     for (i = ats.begin(); i != ats.end(); i++) {
00053        LDAPAttrType at ( (*i) );
00054        StringList names = at.getNames();
00055        // there could be more names for one object...
00056        for (j = names.begin(); j != names.end(); j++) {
00057             string lc_name = *j;
00058             string::iterator k;
00059             for ( k = lc_name.begin(); k != lc_name.end(); k++ ) {
00060                 (*k) = tolower(*k); 
00061             }
00062            attr_types [lc_name] = LDAPAttrType (at);
00063        }
00064     }
00065 }
00066 
00067 LDAPObjClass LDAPSchema::getObjectClassByName (string name) {
00068     string lc_name = name;
00069     string::iterator k;
00070     for ( k = lc_name.begin(); k != lc_name.end(); k++ ) {
00071         (*k) = tolower(*k); 
00072     }
00073     return object_classes [lc_name];
00074 }
00075 
00076 LDAPAttrType LDAPSchema::getAttributeTypeByName (string name) {
00077     string lc_name = name;
00078     string::iterator k;
00079     for ( k = lc_name.begin(); k != lc_name.end(); k++ ) {
00080         (*k) = tolower(*k); 
00081     }
00082 
00083     return attr_types [lc_name];
00084 }